Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting cron task every day at 2am.. makes it run every minute

Tags:

linux

cron

From what I have read, and wizard generators I have used the following should run the task every day at 2am

* 2 * * * <my task here> 

However, looking at the logs it has actually fired the task for each minute in the 2am hour, in other words 60 times in total. What am I doing wrong here? Or are these generators just rubbish. Thanks

like image 624
sectornitad Avatar asked Apr 26 '14 09:04

sectornitad


People also ask

Can I run cron job every minute?

“At every minute.” Cron job every 1 minute is a commonly used cron schedule. We created Cronitor because cron itself can't alert you if your jobs fail or never start.

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

This runs the script every minute of 2am (02:00, 02:01, 02:02 and so on):

 * 2 * * * 

While This runs the script at 02:13am (of each day of each month)

13 2 * * *   * * * * *  command to execute  ┬ ┬ ┬ ┬ ┬  │ │ │ │ │  │ │ │ │ │  │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, 7 is Sunday again)  │ │ │ └────────── month (1 - 12)  │ │ └─────────────── day of month (1 - 31)  │ └──────────────────── hour (0 - 23)  └───────────────────────── min (0 - 59) 
like image 177
guido Avatar answered Sep 18 '22 00:09

guido