How can I run a cron job every 5 minutes starting from a time other than 0 minutes? How can I run a cron job every 5 minutes starting from a time other than 0 minutes? unix unix

How can I run a cron job every 5 minutes starting from a time other than 0 minutes?


Syntax 1

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

For future reference take a look at this online Cron Job Generator.

Syntax 2

Since there are several reports that the + syntax is not working on Ubuntu 14.04, here's a variation:

2-59/5 * * * * 1st-script4-59/5 * * * * 2nd-script

This will result in the 1st script to run every 5 minutes starting with an offset of 2 minutes at the beginning of each hour and the 2nd script to behave the same with an offset of 4 minutes.


or

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

nice thing about this approach is that you can let crontab start things at times other then minute boundaries (like 30 seconds after the hour)


*/5+1 * * * * first_script.sh

To run every five minutes, but offset one minute