Cron every 5 minutes, starting at a specific time

I want the script to run every 5 minutes, starting at 13:02, so I can run another script every 5 minutes, but starting at 13:04, so that the second script runs two minutes after the first work starts. How can this be achieved?

+42
unix cron
Apr 18 '13 at 23:04
source share
3 answers

Use this:

*/5+2 * * * * 1st-script */5+4 * * * * 2nd-script 

In the future, refer to this online Cron Job service.

Update

Since there are several reports that the + syntax does not work on Ubuntu 14.04, there is an option:

 2-59/5 * * * * 1st-script 4-59/5 * * * * 1st-script 

This will cause the 1st script to run every 5 minutes, starting with a shift of 2 minutes at the beginning of each hour, and the second script will behave the same with a shift of 4 minutes.

+76
Apr 18 '13 at 23:11
source share

or

 */5 * * * * sleep 120; ( first_script.sh & ) ; sleep 120 ; second_script.sh 

The good thing about this approach is that you can let crontab run things at different times except minute limits (e.g. 30 seconds after an hour)

+12
Apr 18 '13 at 23:20
source share
 */5+1 * * * * first_script.sh 

Perform every five minutes, but compensate for one minute

+5
Apr 18 '13 at 23:11
source share



All Articles