In order to run cron in the night at 4am, do I need to write 4 * * * *
?
And to run at 4pm o'clock, should it be 16 * * * *
?
In order to run cron in the night at 4am, do I need to write 4 * * * *
?
And to run at 4pm o'clock, should it be 16 * * * *
?
No. This would run at the 4th and 16th minute of every hour.
You're looking for:
That will run at both 4am and 4pm.
Or if the two commands are different:
The first column sets the minutes. In these examples, I'm setting it at 0 so the event happens on the hour.
The in the next column we set the hour you want it to run. We use absolute values but you can use
*/2
for "every other hour", etc.The next column says that we want this to happen every day of the month.
The next column denotes the months that this should trigger on (all in this case).
The last column says which days of the week this is allowed to trigger on. 0-7 (where both 0 and 7 are Sunday).
*
means it can trigger on any day of the week.No, that's not correct. The meaning of the fields
* * * * *
for each asterisk slot respectively:
So for everyday 4am and 4pm you should use:
If you leave a slot just as
*
it will mean every iteration of that time unit i.e. every hour, daily etc.Here, the part
0 4,16
means it will run at 0 minute of 4am and 4pm (i.e 4:00am and 4:00pm). If you wanted to run it at, let's say 15 minutes of 4am and 4pm instead you would change it to15 4,16 * * *
(i.e. 4:15am and 4:15pm).