Cron
Jobb shedules in Obsidian are specified using cron syntax. This page provides a reference for writing your own cron expressions, and documents the cron extensions that Obsidian supports.
Basic Format
Cron expressions are written using 5 fields separated by spaces, as indicated below.
.---------------- minute (0 - 59) | .------------- hour (0 - 23) | | .---------- day of month (1 - 31) | | | .------- month (1 - 12) | | | | .----- day of week (0 - 7) (Sunday = 0 or 7) | | | | | * * * * *
Ordinals indicate specific times, days or months that apply, while an asterisk (*) means there is no restriction on that field. For example, using an asterisk for the month field means the schedule runs during all months, while using "1" would mean it only runs in January. Using 5 asterisks will cause a job to run every minute.
The most basic cron expressions use simple ordinals or an asterisk for each field. As an example, the pattern 30 19 * * 5 means 7:30 PM on all Fridays.
Special Characters and Allowed Values
In addition to ordinals and asterisk, Obsidian supports special characters to support clearer or more complex expressions, as indicated below. These characters allow for ranges, lists and other special handling.
| Field Name | Allowed Ordinal Values | Allowed Special Characters |
|---|---|---|
| Minute | 0-59 | * / , - |
| Hour | 0-23 | * / , - |
| Day of Month | 1-31 | * / , - L W |
| Month | 1-12 or JAN-DEC | * / , - |
| Day of Week | 0-7 or SUN-SAT | * / , - L # |
Special Character Meanings
Asterisk (*)
The asterisk indicates that the cron expression will match for all values of the field. For example, using an asterisk in the 5th field (month) would indicate every month.
Forward slash (/)
Forward slashes are used to describe increments. For example 0/15 in the 1st field (seconds) would indicate the 0th second of the minute and every 15 seconds thereafter.
Comma (,)
Commas are used to separate items of a list. For example, using "MON,WED,FRI" in the 6th field (day of week) would mean Mondays, Wednesdays and Fridays.
Hyphen (-)
Hyphens are used to define ranges. For example, 2000-2010 would indicate every year between 2000 and 2010 CE inclusive.
Question mark (?)
L
'L' stands for "last". When used in the day-of-week field, it allows you to specify constructs such as "the last Friday" of a given month. In the month field, it specifies the last day of the month.
W
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.
Shortcut Expressions
Obsidian supports some shorthand expressions to easily input common expressions. These start with the at sign (@).
| Shortcut | Long-Form Expression | Description |
|---|---|---|
| @yearly | 0 0 1 1 * | Run once a year, on Jan 1st at midnight. |
| @annually | 0 0 1 1 * | Same as @annually. |
| @monthly | 0 0 1 * * | Run once a month, on the 1st at midnight. |
| @weekly | 0 0 * * 0 | Run once a week, on Sunday at midnight. |
| @daily | 0 0 * * * | Run once a day, at midnight. |
| @midnight | 0 0 * * * | Same as @daily. |
| @hourly | 0 * * * * | Run on the hour, every hour. |