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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron Handling of Holidays & Other Non-Working Days 1

Status
Not open for further replies.

ITGoddess

IS-IT--Management
Dec 13, 2001
8
US
Greetings!

I have several cron entries which execute on various schedules. I would like to implement an intelligent method of turning these scripts on and off in order to handle holidays and other non-working days (rather than manually changing cron entries).

What comes to mind is creating a file of non-working days, executing a pre-script that looks at this file and if the current date is equal to a date in this file, tell script(s) not to execute.

Would anyone care to share their methodology and some sample syntax? Any info offered would be greatly appreciated.

Regards,
-Michelle
 
To get you started. Lets say we have a file called holiday_file which contains the list of holiday dates in the form dd-mm-yyyy.

If we have a bit of code like
Code:
TODAY=$(date +%d-%m-%Y)
grep $TODAY holiday_file
DONT_RUN=$?
now, if DONT_RUN = 0, the date was found in holiday_file, so you shouldn't run your scripts

If DONT_RUN = 1, the date wasn't found so your scripts can continue.

Greg.
 
Many Thanks! *:->* That was enough to get me started.

Regards,
-Mcihelle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top