Ubuntu – Cron scheduling: Is the hour argument in 24h format

cron

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 * * * *?

Best Answer

No. This would run at the 4th and 16th minute of every hour.

You're looking for:

0 4,16 * * * command

That will run at both 4am and 4pm.

Or if the two commands are different:

0 4 * * * command
0 16 * * * another_command
  1. The first column sets the minutes. In these examples, I'm setting it at 0 so the event happens on the hour.

  2. 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.

  3. The next column says that we want this to happen every day of the month.

  4. The next column denotes the months that this should trigger on (all in this case).

  5. 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.