[lug] Automatic removal of cron job by cron script

Kenneth D Weinert kenw at quarter-flash.com
Fri Nov 2 17:19:31 MDT 2007


Here's a different idea that might make it a bit easier:

Have the monitor program check for the existence of a flag file when
there's an error. If it's not there, fire off the alert script.

The alert script creates the flag file.

The way to automate that is to have the alert script use a 'start' and
'stop' parameter, so the monitor does:

alert start

and the admins do

alert stop

and on stop, of course, alert deletes the flag file.

Might be a bit of coordinating/training to go on there and this might
not fit your situation, but I thought I'd throw it in just for a
different perspective.


On Fri, 2007-11-02 at 16:10 -0700, karl horlen wrote:
> I've created a cron job script called 'monitor' that
> monitors the health of a hardware component.  When an
> error is detected, I want this script to:
> 
> 1) Call another script called 'alert' to send a
> repeating error message (using an endless loop with
> sleep 2) to the console as an alert for staff.  
> 
> THEN
> 
> 2) Remove the original cron JOB (remove the entry from
> the crontab file from within the original cron script
> 'monitor') versus just killing the actual running
> script 'monitor'.  If I don't remove the job, it will
> keep spawning more 'monitor' processes and I will have
> only killed the last process.
> 
> I don't need the cron to run any longer because my
> 'alert' script will now be running and sending output
> to the console.
> 
> how do I automate removing a sinble cron job from cron
> via script?
> 
> Friday afternoons are not usually good days to ask
> questions but I thought I'd give it a try.
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug




More information about the LUG mailing list