Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have about a one hundred machine set-up with each machine running cron jobs like starting and stopping services and archiving these services' log files at the end of the day to a centralized repository.

One headache we have is the three-day weekend (we're closed on holidays). We don't want the services starting up on those days and connecting to our business partner's machines.

We currently do this by manually commenting out the most critical jobs and letting a bunch of errors happen all day. Not ideal.

Basically if a job has '1-5' set in the day field we want this to mean 'work days' and not Monday to Friday'. We have a database that keeps track of which days are indeed 'work days'

So, is it possible to override Cron's day-matching algorithm, or is there some other way to easily set a cron setting to avoid things starting up on a Monday holiday?


share|improve this question
Do them on a Tuesday instead? – William Hilsum Jan 30 '11 at 14:48
@Wil, the setting 1-5 runs a script each Monday thru Friday, so 5 times a week. Only a few Mondays should be skipped (according to some value from a database). – Arjan Jan 30 '11 at 14:50
@Arjan - :S it was just a jokey thing anyway! I didn't read all the way through :( thanks for that! – William Hilsum Jan 30 '11 at 15:31

Cron doesn't support this kind of determination. It gets very complicated very fast. Here in Canada, the holidays aren't even consistent between provinces.

I would write a runner script that check a holiday database and exits if it is a holiday. Try something like:


TODAY=$(date +%Y%m%d)
if grep -q $TODAY /etc/holidays; then
   echo Skipping holiday for $*
   exit 0

share|improve this answer
You should leave off the square brackets. I'm assuming -1 stops on the first match (in GNU grep it's -m 1). You could also use -qs or > /dev/null >&2 to suppress output. – Dennis Williamson Jan 30 '11 at 15:43
@Dennis Updated. Got distracted while writing the script. – BillThor Jan 30 '11 at 15:50

I can imagine a few ways of doing this but the most practical solution will depend on the exact setup of all the cron jobs. For example:

If the work day database can be interrogated via a script, you could have a cron job run on Sunday that determines whether the next day (Monday) is a working day or not and sets/clears a file somewhere. All the cron jobs could look for the presence of this file and choose to run or exit accordingly.


You could replace all the individual cron entries with one master job that only fires off all the others if the (checkable) database says it's a working day.

share|improve this answer

Your Answer


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.