On 07/03/12 16:41, James Bensley wrote:
Then in the script, when it starts up, check there isn't an instance already running, if there's not, drop to infinite loop;
while true do echo "hello" sleep 1 done
Or is this just silly?
It's the approach that seems to be generally considered to be correct, and I've done it this way before.
However the downside is that control of the process is now duplicated in cron and my script. So, for example, if my script crashes for some reason, that's it dead now for the remainder of the minute. So ideally I create a wrapper script that does some job control (each second checks to see if the script is already running, probably kills it if it is (it should never take longer than 1s to run), starts it again, and monitors it for any signs that it died unexpectedly and reports it.
As it happens I have just found the following way down on a Google search: http://linuxnotes.us/archives/425
It seems to do all I want it to do, albeit in quite a convoluted way to set up. I don't really understand why nobody has tweaked cron to support an extra seconds parameter - there seem to be lots of people wanting it, which makes me wonder if there's an underlying reason why it isn't already done?
Mark