3
votes

Scenario

We have a use-case where we need to run a program every minute for some number of hours (let's say 8, but ending on an hour boundary), but we need the program to start running at 6:30am (on the half hour)

I was recently asked if this scenario is possible in a single cronstring, and I can't seem to find a way to do it since the minute area is needed to match both the half hour start time and the execute every minute.

I can see how to do it in two cronstrings, 1 from 6:30am - 7:00am then another from 7:00am-3:00pm

30-59 6    * * * /path/to/my/program.sh
*/1   7-15 * * * /path/to/my/program.sh

Is there anyway to combine these into a single cronstring ?

1
Short of teaching cron new crontab format your approach is probably the only one. You could write some sort of wrapper script which would be run every minute, but which would start the real job only if the time is right. - ArtemB
Agree with ArtemB. Keep in mind, that crond does not guarantee execution on every minute. - Daniel

1 Answers

-1
votes

you can change Time in your PC to 7:00 ot 6:00 when it is 6:30 if it doesn't matters to you