Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron : Setting multiple minutes

Tags:

cron

crontab

With cron, if I wanted to run a command every 5 mins it would be:

*/5 * * * * command 

But what if I wanted to set a list of minutes specifically?

Like at 5 past, 18 mins past and 15 minutes too the hour? I'm guessing this:

5,18,45 * * * * 
like image 324
cosmicsafari Avatar asked Mar 30 '12 15:03

cosmicsafari


People also ask

How do I run a cron job every 5 minutes?

basic 3. /usr/bin/vim. tiny 4. /bin/ed Choose 1-4 [1]: 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.

How do I run a cron job every 5 seconds?

Cron only allows for a minimum of one minute. What you could do is write a shell script with an infinite loop that runs your task, and then sleeps for 5 seconds. That way your task would be run more or less every 5 seconds, depending on how long the task itself takes.


1 Answers

Yes, the solution you specified is correct.

0,5,55 * * * * command       # run the command at the top of the hour, at                              # the 5 minute mark and at the 55 minute mark. 
like image 84
Overv Avatar answered Oct 15 '22 16:10

Overv