Use PHP to read cron launched php scripts?
Hey guys,
I have a php script that runs at regular intervals on my LAMP machine. It mostly just checks scores of sports games and such and then emails them to my phone for when I'm away from the games. I was mostly just curious if there was a way to report (possibly using AJAX and php) to check to see when the script is currently running.
What I currently have set up is a field in an sql table that says whether or not the script has been launched or not. In the beginning of the script it marks the changes the 'active' field to 1. At the end of the script it sets the active field to 0. The problem I am having with this is that if the script ever fails during it's run, it never marks the script as un-active.
So what I'm hoping I can do is check at the linux level whether or not the process is running.
Is there any way to do that with PHP (it happens to be the language I'm familiar with)?
I know PHP has a system() function that allows the programmer to run actual calls from the command line and then maybe it's possible to parse the output?
Maybe something like "system('ps aux | grep 'php pathtophp/script.php?id=soccer')" ?
Any ideas or tips in the right direction are fully appreciated!
|