Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using batch process to edit live crontab 2

Status
Not open for further replies.

jgrogan

MIS
Oct 8, 2001
21
GB
Hi

Is it possible to 'script' an edit (i.e. batch edit) an existing crontab? If so, how would I go about it?

I am effectively asking if 'crontab -e' is scriptable, using sed-like syntax to edit a line (to add a '#' to a scheduled command in the crontab) to stop execution of that command.

Thanks
JG
 
[tt]crontab -l >/tmp/safekeep
crontab -l >/tmp/whatever
edit /tmp/whatever
crontab /tmp/whatever[/tt]

but I'd experiment with a test user's crontab before going live on a system crontab file...


HTH,

p5wizard
 
I use ex to do scripted crontab edits, e.g. to disable the cron job containing the string "badjob":

[tt]$ echo '/badjob/s/^/#/
wq' | EDITOR=ex crontab -e[/tt]

Annihilannic.
 
my answer would be not to mess with cron, but
to create a go/no-go file somewhere on the system
where the cron-job first looks before it executes.

or put the decision to run/not-run in the script itself or
a wrapper script.

no reason to get fancy here.
 
When you need to make the same edit to crontabs on 400 systems sometimes getting fancy is worth the effort.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top