Skip to content

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!



nohup is your friend.

nohup command &
User contributions licensed under: CC BY-SA
5 People found this is helpful