Best way to run a PHP-CLI script forever.
Last time I looked this up there were several options.
I would love to hear some suggestions.
Let's say I have a PHP script running in an endless loop on my Fedora VPS doing various things for me all day long and I want it to run forever, even when I'm not logged in.
Also: If the script dies for some reason, I would like to see the last moments of its death (say I'm drawing cool stuff to the terminal, not keeping an error log.)
Thanks!
2 Replies
The easiest way to run it in the background and see the output (other than redirecting stdout and stderr to a file) might be to use screen.
@Guspaz:
The same way that any other program does? usleep() in a loop, or if you're waiting on a network socket, socket_select() with a null timeout (blocks forever until there's network activity to handle)?
The easiest way to run it in the background and see the output (other than redirecting stdout and stderr to a file) might be to use screen.
Thanks Guspaz, I was thinking of "screen" but I couldn't remember the name.