I have a cronjob which runs every 5 minutes all the day in a week. I want to stop this cronjob for 2 hrs only on Sunday. Could you pls help me to set this.

link|improve this question
Also asked over at superusers, answers given there as well superuser.com/questions/307625/… – Viper_Sb Jul 7 '11 at 14:36
feedback

1 Answer

Rather than mess with esoteric crontab schedule entries, have your script check for a file and to not do a full run if the file is present. Then, schedule a second script in cron to create that file on Sunday at the time you want the other script to stop, and then another script 2 hours later in cron to remove the file.

That way, you can be flexible about when the main script does and doesn't run by just changing the times of the create/remove scripts.

link|improve this answer
1  
In addition to simplicity, this approach also provides a way for you to easily and temporarily "pause" your script if you are doing some other work that might interfere, via a simple command like "touch /etc/myscript/pause", or whatever your "pause file" is called. Then "unpause" with "rm /etc/myscript/pause". – Ryan Fisher Jul 7 '11 at 17:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.