CRON is a job scheduler, it enables automation of tasks execution at specified time intervals.
A CRON is usually made of six required fields, as seen below.
Field | Allowed values |
Second* | 0-59 |
Minute | 0-59 |
Hour | 0-23 |
Day (month) | 1-31 |
Month | 1-12 OR JAN-DEC** |
Day (week) | 0-6 OR MON-SUN** |
- omitted in some implementations
- * case-insensitive
Shooju uses APScheduler, which supports the following expression types:
Expression | Field | Description | Example |
* | any | Runs on every value | An asterisk in the minute field is equivalent to run every minute |
a/b | any | Skips a given number of values | */3 in the hour field corresponds to run every three hours |
a-b | any | Runs on a specified range of values | 1-4 in the day (week) field is equivalent to only run Tuesdays to Fridays |
a,b | any | Runs on a specified list of values | Running every day at 15 and 23 corresponds to 15,23 in the hour field |
xth_y | day | Fire on the x -th occurrence of weekday y within the month | |
last_x | day | Fire on the last occurrence of weekday x within the month | |
last | day (month) | Runs on last day of the month |
Cron Examples
Cron | Description |
15 30 4 * * MON | at 4:30:15 on every Monday |
* * */2 * * * | every two hours |
* 0 8,10,15 1-5 * * | at 8, 10 and 15 on first five days of the month |
15 30 5 last * * | at 5:30:15 on every last day of the month |
0 0 5 1st_fri * * | at 5:00:00 on every first friday of the month |
0 0 5 last_sun * * | at 5:00:00 on every last sunday of the month |
* * * 1-7 * 5 | first saturday of the month |
Note that jobs between 12 am and 1 am may cause a skip or repeat job schedule depending on CRON timezone
Bear in mind external helpers such as https://crontab.guru/ and http://www.cronmaker.com/ are available for guidance but may not reflect same syntax as supported by Shooju