I have a script startbg.php
:
echo `/usr/bin/php $dir/runbg.php >> $dir/logbg.txt 2>&1 &`;
Which I call from the web (via HTTP/Apache).
It runs runbg.php
in a background process.
But if I restart Apache (/etc/init.d/apache2 restart
), the background process is killed.
Is there anyway I can keep the process running in the background?
You could open up an instance of PHP's internal webserver (As of PHP 5.4.0, the CLI SAPI provides a built-in web server.) in my test killing httpd.exe
did not effect php.exe:8000
<?php
//Tested with windows
chdir('../php');
//S = Server, listen interface 0.0.0.0 = all : port 8000
//t = Served document root
echo `php -S 0.0.0.0:8000 -t C:\\xampp\\htdocs >> C:\\xampp\\htdocs\\logbg.txt 2>&1 &`;
?>
So possibly (untested):
echo `/usr/bin/php -S 0.0.0.0:8000 -t /srv/www/yoursite.com/public_html >> /srv/www/yoursite.com/public_html/logbg.txt 2>&1 &$dir/runbg.php >> $dir/logbg.txt 2>&1 &`;
Tho id have no idea how to kill it :s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With