Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|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
add comment

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.

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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