Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

unix

cron

I would like to have a script run every 5 minutes let's say starting from 13:02 so I can have another script runs every 5 minutes but starting from 13:04 so the second script runs two minutes after the start of the first job. How can I achieve this?

like image 935
RazorHead Avatar asked Apr 18 '13 23:04

RazorHead


People also ask

How do I schedule a cron job to run every 5 minutes?

Make a new line at the bottom of this file and insert the following code. Of course, replace our example script with the command or script you wish to execute, but keep the */5 * * * * part as that is what tells cron to execute our job every 5 minutes.

What is the cron expression for every 5 minutes?

“At every 5th minute.” Cron job every 5 minutes is a commonly used cron schedule. We created Cronitor because cron itself can't alert you if your jobs fail or never start. Cronitor is easy to integrate and provides you with instant alerts when things go wrong.

How do I run a cron job after every minute?

Execute Cron Job After System Reboot. Setup and Run PHP Script As A Cron Job. Run crontab job every minute on a Linux or Unix-like system.

What is the use of * * * * * In cron?

It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .


1 Answers

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-script 4-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.

like image 194
Rolando Isidoro Avatar answered Sep 18 '22 04:09

Rolando Isidoro