[lug] Automatic removal of cron job by cron script
Hugh Brown
hugh at math.byu.edu
Fri Nov 2 19:37:49 MDT 2007
karl horlen wrote:
> Thanks Mike and Ken
>
> I should have thought of this. Easy enough and fine
> for what I need to do.
>
> Since this post is out there. If anyone has
> suggestions for removing the job from cron, have at
> it. I'm curious how it might be done.
>
It depends on how you made cron aware of your script.
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.
Another consideration about putting alerts to the console, if you do it
so fast and furious that you can't get logged in, you've defeated the
purpose of the alert (and likely brought the system to its knees).
Hugh
More information about the LUG
mailing list