I'm using watch
in a screen
window to continually execute a PHP task which processes data every two seconds. Thus, I can logout of the server with it running and can check-in on it. I don't want to stop the task mid stream because it requires manual cleaning up if that happens, but I'd like to be able to reboot the server. Is there a way to stop watch between runs and be sure it hasn't started another copy of the task? Ie something like ctrl+c but that waits if the task is running in the background.
Alternatively, is there some other workflow that would accomplish this? I can't use a cron job since it needs to run every two seconds but never concurrently.
Also note, one run of the script takes between 10 seconds and 30 minutes depending on how big the data object is. (It processes one object per run.) This is why stopping watch between runs is very unlikely...