[lug] Automatic removal of cron job by cron script

karl horlen horlenkarl at yahoo.com
Tue Nov 6 00:22:02 MST 2007


Thanks for this idea.  

After the script runs sed on the cron file, is the
edited file automatically picked up in the next cron
run or does it need to be "reactivated" again?

For instance, I'm used to using crontab -e which
simultaneously makes the edit and "activates" the
changes.  This requires interactively editing the
file.  Since your method runs entirely from scripts,
it sounds like the changes are automatically picked
up.


> I have two modes that I like to use.  The first mode
> is to add a file to 
>   one of the files in
> /etc/cron.{d,hourly,weekly,daily}.  If added that 
> way, then it should suffice to remove it or to have
> sed comment out all 
> the lines in the file.
> 
> The other way I've done it is to keep a file named
> crontab in ~/ and 
> edit that.  When I'm done editing, I run crontab
> ~/crontab and my 
> changes are active.  Again, to disable the cronjob,
> you'd run sed to 
> comment out the line you didn't want.
> 
> If you don't keep a crontab file in ~/, you could do
> "crontab -l 
>  >~/crontab" and then do as above.
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the LUG mailing list