76 lines
3.6 KiB
Plaintext
76 lines
3.6 KiB
Plaintext
|
The following is greatly inspired by python-crontab (https://pypi.python.org/pypi/python-crontab), Wikipedia (https://en.wikipedia.org/wiki/Cron#CRON_expression).
|
||
|
|
||
|
Field Name Mandatory Allowed Values Special Characters Extra Values
|
||
|
Minutes Yes 0-59 * / , - < >
|
||
|
Hours Yes 0-23 * / , - < >
|
||
|
Day of month Yes 1-31 * / , - < >
|
||
|
Month Yes 1-12 or JAN-DEC * / , - < >
|
||
|
Day of week Yes 0-6 or SUN-SAT * / , - < >
|
||
|
Year No 2015-2100 * , -
|
||
|
|
||
|
Extra Values are < for minimum value, such as 0 for minutes or 1 for
|
||
|
months. And > for maximum value, such as 23 for hours or 12 for
|
||
|
months.
|
||
|
|
||
|
Supported special cases allow crontab lines to not use fields. These
|
||
|
are the supported aliases which are not available in SystemV mode:
|
||
|
Case Meaning
|
||
|
@reboot Every boot
|
||
|
@hourly 0 * * * *
|
||
|
@daily 0 0 * * *
|
||
|
@weekly 0 0 * * 0
|
||
|
@monthly 0 0 1 * *
|
||
|
@yearly 0 0 1 1 *
|
||
|
@annually 0 0 1 1 *
|
||
|
@midnight 0 0 * * *
|
||
|
|
||
|
Comma ( , ) Commas are used to separate items of a list. For example,
|
||
|
using "MON,WED,FRI" in the 5th field (day of week) means Mondays,
|
||
|
Wednesdays and Fridays.
|
||
|
|
||
|
Hyphen ( - ) Hyphens define ranges. For example, 2000-2010 indicates
|
||
|
every year between 2000 and 2010 AD, inclusive.
|
||
|
|
||
|
Percent ( % ) Percent-signs (%) in the command, unless escaped with
|
||
|
backslash (\), are changed into newline characters, and all data
|
||
|
after the first % are sent to the command as standard input.
|
||
|
|
||
|
L 'L' stands for "last". When used in the day-of-week field, it allows
|
||
|
you to specify constructs such as "the last Friday" ("5L") of a
|
||
|
given month. In the day-of-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 fires on Friday the 14th. If the 15th is a Sunday, the
|
||
|
trigger fires on Monday the 16th. If the 15th is a Tuesday, then
|
||
|
it fires on Tuesday the 15th. However, if you specify "1W" as the
|
||
|
value for day-of-month, and the 1st is a Saturday, the trigger
|
||
|
fires on Monday the 3rd, as it does not 'jump' over the boundary
|
||
|
of a month's days. The 'W' character can be specified only when
|
||
|
the day-of-month is a single day, not a range or list of days.
|
||
|
|
||
|
Hash ( # ) '#' is allowed for the day-of-week field, and must be
|
||
|
followed by a number between one and five. It allows you to
|
||
|
specify constructs such as "the second Friday" of a given
|
||
|
month.[13]
|
||
|
|
||
|
Question mark ( ? ) In some implementations, used instead of '*' for
|
||
|
leaving either day-of-month or day-of-week blank. Other cron
|
||
|
implementations substitute "?" with the start-up time of the cron
|
||
|
daemon, so that ? ? * * * * would be updated to 25 8 * * * * if
|
||
|
cron started-up on 8:25am, and would run at this time every day
|
||
|
until restarted again.[14]
|
||
|
(WON'T BE IMPLEMENTED)
|
||
|
|
||
|
Slash ( / ) In vixie-cron, slashes can be combined with ranges to
|
||
|
specify step values.[6] For example, */5 in the minutes field
|
||
|
indicates every 5 minutes (see note). It is shorthand for the more
|
||
|
verbose POSIX form 5,10,15,20,25,30,35,40,45,50,55,00. POSIX does
|
||
|
not define a use for slashes; its rationale (commenting on a BSD
|
||
|
extension) notes that the definition is based on System V format
|
||
|
but does not exclude the possibility of extensions.[5]
|