Help with cron schedule

Hope you can help with a queuy i have. Server OS is HP-UX
my cron runs like this:

 
* * * * * /test/scripts/1_min_jobs.sh 1>/dev/null 2>/dev/null
 
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /test/scripts/jobs_5mins.sh 1>/dev/null 2>/dev/null
 
0,15,30,45 * * * * /test/scripts/jobs_15mins.sh 1>/dev/null 2>/dev/null

I need to be able to stop them running (or change the cron so they do not run) at 19:45 on saturday until 8:05 on Sunday
for this year (2013)

he outage periods for the rest of 2013 are Sat 5th/Sun 6th October, Sat 9th/Sun 10th November, Sat 7th/Sun 8th December.

Any ideas how i schedule this as a cron that i can set and not need to look at it again?

Thanks
Dave

While possible in cron (with multiple entries to handle all the rules), I wonder if a better solution is to address the 'skip times' at the very beginning of the called program?

I wonder if it could also work, that you use the at daemon to stop and start the cron daemon at the appropriate times?

it would not be a bad idea to use 'at' if there was not other crons in use at that specific time. unfortunately these are all we are asked to halt. Any other ideas? cron examples?

You could setup a new job (cron or at) to swap in an alternative cron file that omits / adds those entries, at the desired times. Alternatively you could do as joeyg suggests and fashion a load of cron entries to meet the requirement, or add a time check to each of the affected scripts.

What about a at job that replaces the cronfile (removes the jobs...) and reload, then at end time of schedule an at job for restoring the cronfile and reload again ?

:smiley: You were faster than me Scott...

Thanks All. Good feedback. Say i do it via 'at' do you have any command references to hand? maybe an idiots guide thats better than the MAN page? :slight_smile:

It uses the same time specification as touch, so like:

$ at -f myScriptTemp -t 201309251915
job 2 at 2013-09-25 19:15

...and another for myScriptReal (pick your own, better names :))

Where myScriptTemp swaps in the new cron file:

crontab tempCrontabFile

And myScriptRead does the opposite:
Where myScriptTemp swaps in the new cron file:

crontab realCrontabFile

It might just be easier to add a new cron job (one each in the main and temporary files, each replacing the other).

Thanks all that responded. Good Information,

Another idea:

* * * * * /test/scripts/enabler /test/scripts/1_min_
jobs.sh 1>/dev/null 2>/dev/null
0,5,10,15,20,25,30,35,40,45,50,55
* * * * /test/scripts/enabler /test/scripts/jobs_5mins.sh 1>/dev/null 2>/dev/null
0,15,30,45 * * * * /test/scripts/enabler /test/scripts/jobs_15mins.sh 1>/dev/null 2>/dev/null

And /test/scripts/enabler

#!/bin/sh
test -f /test/run &&
exec "$@"

Now you can add further cron jobs that create or delete /test/run (or rename to dont_run).