I have a php loop that I want to constantly run. Currently if you leave x.php running in your browser then it loops forever. as long as you have the browser window open… and it works great.
How do I get it to run constantly without me having to sit with a browser tab open on it? I want it to run 24/7 and if it ever stops running. it needs to restart itself.
Thanks
Can you run it from the command line?
With
nohupit’ll keep running even if the user logs out.The cron solutions in other answers will start a new instance each time they are run – not sure if you want that. However if the script dies and you want to restart it, then you will have to run a separate daemon that checks if it’s running and if not, start it. You could make a simple script that does the check and starts running it, and then cron that script to run say every 5 minutes or however often you want.