I’m running a php script via cli, so it can run in background. This script is suposed run 24/7. How can I prevent it from shutting down (on errors, warnings, etc) and restart immediatly if it happens?
Thanks in advance!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use a shell script to call php in an infinite loop, and run the shell script in the background. For example (a bit simplistic) a script like this, say “runloop.sh”:
…and then run that script in the background, or from init. From the command prompt:
…to run the script in the background. It should run forever, unless you kill it somehow.
I should add that you’ll need to make the shell script executable: