How to easily run a PHP script in the background via terminal

Posted at August 02, 2012

I’m writing a PHP script that is going to serve as a daemon on my own server. As I’m writing it I want to test it a lot to make the daemon as stable as possible. Yesterday I wanted to let the script run overnight to monitor memory usage and make sure it didn’t crash.

If you don’t want to bother setting up a cron you can just run:

nohup php [file.php] &

All the output (stuff you echo) will be stuffed in nohup.out.

Posted at August 02, 2012, under PHP.