Custom Crontab Tasks¶
A Crontab expression is a string used to configure scheduled tasks, consisting of five or six fields that represent seconds, minutes, hours, days, months, weeks, and optionally, years. Each field uses numbers and can employ specific symbols to define value ranges or steps.
The general basic format is: minute hour day month week.
Note
Monitor > Threshold Detection supports configuring second-level syntax detection, with the format: 0 - 59, indicating the second within a minute.
Example:
Detection frequency of 30 seconds: */30 * * * * *
Value Range Explanation¶
- Minute: 0 - 59, indicating the minute within an hour
- Hour: 0 - 23, indicating the hour within a day
- Day: 1 - 31, indicating the day within a month
- Month: 1 - 12, indicating the month within a year
- Week: 0 - 6, indicating the day within a week, where 0 represents Sunday
Special Characters¶
Includes -
*
/
,
:
*
: Can be any value. For example, * * * * * means executing every minute.-
: Value range. For example, 0-10 * * * * means executing every minute from the 0th to the 10th minute of each hour./
: Step definition. The value before / indicates the starting minute, and the value after / indicates the interval. For example, */10 * * * * means executing every 10 minutes.,
: Multiple value specification, separated by commas. For example, 0,3,12,18 * * * * means executing at the 0th, 3rd, 12th, and 18th minutes of each hour.
Crontab Examples¶
* * * * *
: Execute the scheduled task every minute
0 * * * *
: Execute the scheduled task at the 0th minute of every hour
0 0 * * *
: Execute the scheduled task at 0:00 every day
0 0 1 * *
: Execute the scheduled task at 0:00 on the 1st day of every month
0 0 1 1 *
: Execute the scheduled task at 0:00 on January 1st every year
0 0 * * 0
: Execute the scheduled task at 0:00 every Sunday
0-10 * * * *
: Execute the scheduled task every minute from the 0th to the 10th minute of each hour
*/10 * * * *
: Execute the scheduled task every 10 minutes
0,3,12,18 * * * *
: Execute the scheduled task at the 0th, 3rd, 12th, and 18th minutes of each hour