Andrew Bashtannik Andrew Bashtannik - 1 year ago 136
Linux Question

How to run infinitely script in background on Linux?

I have a PHP script with infinite loop. I need this script running forever. So, I run

php /path/to/script.php > /dev/null &

And it works in background in my current user's security context. But when I close terminal window (log off), of course, CentOS Linux kills my program.

I see two guesses: run from a different user in background or make a daemon. I need help in each situation.

Thanks a lot!

Answer Source

nohup is your friend.

nohup command &
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download