I want launch simple php daemon on Ubuntu without fork.
source f.php:
#!/usr/bin/php
<?php
file_put_contents('/var/www/3.txt',date("H:i:s", time()) . "\n", FILE_APPEND);
while (true) {
file_put_contents('/var/www/3.txt',date("H:i:s", time()) . "\n", FILE_APPEND);
sleep(1);
}
launch:
root@ubuntu:/var/www# ./f.php &
[3] 10323
On FreeBSD this work well on Ubuntu file 3.txt is not updating 🙁
permissions are ok (777)
can you check that the path you are pointing to for the binary file of PHP is correct, i mean PHP is really installed in /usr/bin/php, you can check that by using below command
also you can try to run it manually instead of running it as an executable by below command
and also check if your php file is giving any errors in apache logs, you can find apache logs in
/var/log/apache2/error.logand also make sure that
php5-clipackage is installed by executing following commandUpdate:
according to http://www.freelance-it-consultant.com/blog/php-cli-script-running-background-ubuntu, there is some bug in ubuntu when php is run through CLI it expects some input from user, so can you try this method if that works for you?