0

I'm programming a website where I want a daemon to be executed when the user click on "execute the background programm". For this, I've developped it with the symfony2 php framework.

For the moment, when I click on the link to execute the daemon, it blocks all the whole website and I can't click other links of my website because the web browser is like searching the page during the execution of the daemon writing "Connexion" as title of the internet page.

My php daemon is written like that :

<?php
while(true) { 
//code
sleep(2);
}
?>

And when I click on the link "execute the background programm", it runs this command :

shell_exec('nohup php /my/daemon/daemon.php &');

Is there a way to run a php daemon without have the "Connexion" status during the execution of my daemon which blocks my website ?

Thanks !

AugJ
  • 1
  • Did I understand it right that `shell_exec` doesn't return? If that is the case, does it return if you use `'nohup php /my/daemon/daemon.php 0>/dev/null &>/dev/null &'`? – Siguza Aug 03 '15 at 08:45
  • Oh yes thank you with the method you give I have no more the problem ! But what does "0>/dev/null &>/dev/null &" do exactly ? – AugJ Aug 03 '15 at 09:31
  • Redirect input, output and error streams of the spawned process to nothingness. – Siguza Aug 03 '15 at 09:42
  • Ah ok ! And if I want to get the PID of the nohup process that runs in the background, what can I put ? – AugJ Aug 03 '15 at 13:22
  • https://stackoverflow.com/q/1908610 – Siguza Aug 03 '15 at 13:23

0 Answers0