I'm trying to make a PHP script run in the background: $php -q myscript.php & [1] 12345 $jobs [1]+ Stopped php -q myscript.php If I force it into the foreground (fg 1) it runs fine, and if I then stop it (ctrl-Z) and force it into the background (bg 1) it continues to run just fine. It's just starting in the background that seems to be a problem. The script is very simple for test purposes: <?php echo "hello"; ?> (I've tried various scripts, and obviously if I want to stop it and force it into the background it needs to run longer than this, so I just add a sleep(10); to the code.) Googling hasn't got me anything except suggestions that what I am doing is fine! I have no idea if this is a PHP issue or a Linux one? Mark -- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) @ 13 Clarke Rd, Milton Keynes, MK1 1LG
Continuing the recent theme of replying to oneself.... http://ubuntuforums.org/showthread.php?t=977332 The php CLI binary is expecting input from STDIN, and so: php -q myscript.php </dev/null & .. will work. Seems to be a bug (or mis-feature) in the Ubuntu binaries. Bizzarely, after all my (failed) attempts at crafting a good search query to find this, I found it by googling for the exact subject of my email.... (Doh!) -- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) @ 13 Clarke Rd, Milton Keynes, MK1 1LG
participants (1)
-
Mark Rogers