Cron style schedules in KeyHelp Print

  • keyhelp, cron, cron syntax, scheduled tasks
  • 28

Cron style lets you set a schedule that the preset intervals in the panel do not cover. The schedule is written as five values separated by spaces, each saying when the task should run. See Scheduled tasks (cron) in KeyHelp for creating the task itself.

The five fields

Position Field Allowed values
1Minute0–59
2Hour0–23
3Day of month1–31
4Month1–12
5Day of week0–7 (0 and 7 are Sunday)

Within a field you can use:

  • * — every value;
  • 5 — one specific value;
  • 20,30 — several values;
  • 1-5 — a range;
  • */15 — a step, meaning every 15th value.

Examples

* * * * *Every minute
0 0 * * *Every day at midnight
5 * * * *Five minutes past every hour
*/15 * * * *Every 15 minutes
0 * 15 * *On the 15th of the month, every hour
15 20 * * 6Every Saturday at 20:15
20,30 1 * * 1-5Monday to Friday at 1:20 and 1:30

Keywords

The five fields can be replaced by a single keyword:

Keyword Meaning Equivalent
@rebootOnce at system start
@hourlyOnce an hour0 * * * *
@daily / @midnightOnce a day0 0 * * *
@weeklyOnce a week0 0 * * 0
@monthlyOnce a month0 0 1 * *
@annually / @yearlyOnce a year0 0 1 1 *

Two things that catch people out

Day of month and day of week together. If both fields are set to something other than *, the task runs when either matches, not both. So 0 0 13 * 5 runs on the 13th of every month and on every Friday — not only on Friday the 13th.

Steps start from zero, not from now. */15 in the minute field means minutes 0, 15, 30 and 45 — not "15 minutes from when I saved this".

Before you choose every minute

A job running every minute is rarely necessary and quietly costs resources — especially if the previous run has not finished when the next one starts. Ask what the longest acceptable delay is and use that; every 5 or 15 minutes is enough for almost everything.

If you are not sure the schedule you have written means what you intend, describe in a ticket when the task should run and we will check it.


Was this answer helpful?

« Back