I am working on a cron script that will be executed every x minutes, probably every 60 minutes.
On the first execution of the day, an xml file will be loaded and validated, and a timer file will be created and timestamped. Each block of the xml file will be sent off to a processing script which will return that block of xml with a status of success or failure as an attribute at the node name. That node will be saved to a daily activity file with the attribute set to success or failure. Also, at the end of the execution of this script, the time file is unset.
On all the subsequent executions of the day, (run until all nodes return success), I check the timer file to see if the timer file exists. If it does, I check the timestamp to see if the process is stuck. This will also mean that the last iteration of my script is still running. If it is determined that the script is “stuck”, then I want to stop the old script and proceed with the current iteration. If it is determined that the script is not stuck, but running normally, then I want the current script to go to sleep and check again in 10 minutes.
My question is how to stop the script that is already running to all the current script to continue???