ESET PROTECT On-Prem

Offline | Go online

ESET PROTECT On-Prem – Table of Contents

# Cron expression interval

Copy current article URL Share via email

A CRON expression is used to configure specific instances of a trigger. Mostly for scheduled repetitive triggering. It is a string consisting of 6 or 7 fields that represent individual values of the schedule. These fields are separated by space and contain any of the allowed values in various combinations.

CRON expression can be as simple as this: * * * * ? * or more complex, like this: 0/5 14,18,3-39,52 * ? JAN,MAR,SEP MON-FRI 2012-2020

List of values you can use in the CRON expression:

Name | Required | Value | Allowed Special Characters
--- | --- | --- | ---
Seconds | Yes | 0-59 | ,—* / R
Minutes | Yes | 0-59 | ,—* / R
Hours | Yes | 0-23 | ,—* / R
Day of the month | Yes | 1-31 | ,—* / ? L W
Month | Yes | 1-12 or JAN-DEC | ,—*/
Day of the week | Yes | 0-6 or SUN-SAT | ,—/ ? L #
Year | Yes | 1970-2099 | ,—* /

CRON expression syntax is following:

┌────────── Seconds (0–59) │ ┌────────── Minutes (0–59) │ │ ┌────────── Hours (0–23) │ │ │ ┌────────── Day of the month (1–31) │ │ │ │ ┌────────── Month (1–12 or JAN-DEC) │ │ │ │ │ ┌────────── Day of the week (0–6 or SUNSAT)(for example, 0 is the same as SUN) │ │ │ │ │ │ ┌────────── Year │ │ │ │ │ │ │ * * * * * ? *

•The 0 0 0 means midnight (seconds, minutes, hours).

•Use ? when a value cannot be defined because it was defined in other field (day of the month or day of the week).

•The * means every (seconds, minutes, hours, day of the month, month, day of the week, year).

•The SUN means on Sunday.

|  | The names of months and days of the week are not case sensitive. For example, MON is equal to mon, or JAN is equal to jan.

## Special characters:

Comma (,)

Commas are used to separate items of a list. For example, using "MON,WED,FRI" in the 6th field (day of the week) means Mondays, Wednesdays and Fridays.

Hyphen (-)

Defines ranges. For example, 2012-2020 indicates every year between 2012 and 2020, inclusive.

Wildcard (*)

Used to select all possible values within a field. For example, * in the minute field means every minute. The wildcard cannot be used in day of the week field.

Question mark (?)

When choosing a specific day, you can specify either day of the month or day of the week. You cannot specify both. If you specify day of the month, you must use ? for day of the week and vice versa. For example, if you want the trigger to fire on a specific day of the month (say, the 10th), but don’t care what day of the week that happens to be, put 10 in the day of the month field and ? in the day of the week field.

Hash (#)

Used to specify "the nth" day of the month. For example, the value of 4#3 in the day of the week field means the third Thursday of the month (day 4 = Thursday and #3 = the 3rd Thursday in the month). If you specify #5 and there is not 5th of the given day of the week in the month, then the trigger will not fire that month.

Slash (/)

Describes increments of a range. For example 3-59/15 in the 2nd field (minutes) indicate the third minute of the hour and every 15 minutes thereafter.

Last (L)

When used in the day of the week field, it allows you to specify constructs such as the last Friday (5L) of a given month. In the day of the month field, it specifies the last day of the month. For example, day 31 for January, day 28 for February on non-leap years.

Weekday (W)

The W character is allowed for the day of the month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you specify 15W as the value for the day of the 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. However, if you specify 1W as the value for day of the 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 L and W characters can also be combined in the day of the month field to result in LW, which translates to last weekday of the month.

Random (R)

The R is a special ESET PROTECT On-Prem CRON expression character that allows you to specify randomized time moments. For example, R 0 0 * * ? * trigger fires every day at 00:00 but at a random second (0-59).

|  | We recommend that you use randomized time moments to prevent all ESET Management Agents from connecting at the same time to ESET PROTECT Server.

Real examples that illustrate some variations of the CRON expression:

CRON expression | Meaning
--- | ---
0 0 12 * * ? * | Fire at 12 pm (noon) every day.
R 0 0 * * ? * | Fire at 00:00 but at random second (0-59) every day.
R R R 15W * ? * | Fire at 15th every month at random time (seconds, minutes, hours). 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.
0 15 10 * * ? 2016 | Fire at 10:15 am every day during the year 2016.
0 * 14 * * ? * | Fire every minute starting at 2 pm and ending at 2:59 pm, every day.
0 0/5 14 * * ? * | Fire every 5 minutes starting at 2 pm and ending at 2:55 pm, every day.
0 0/5 14,18 * * ? * | Fire every 5 minutes starting at 2 pm and ending at 2:55 pm, and fire every 5 minutes starting at 6pm and ending at 6:55 pm, every day.
0 0-5 14 * * ? * | Fire every minute starting at 2 pm and ending at 2:05 pm, every day.
0 10,44 14 ? 3 WED * | Fire at 2:10 pm and at 2:44 pm every Wednesday in March.
0 15 10 ? * MON-FRI * | Fire at 10:15 am every weekday (Monday, Tuesday, Wednesday, Thursday and Friday).
0 15 10 15 * ? * | Fire at 10:15 am on the 15th day of every month.
0 15 10 ? * 5L * | Fire at 10:15 am on the last Friday of every month.
0 15 10 ? * 5L 2016-2020 | Fire at 10:15 am on every last Friday of every month from the year 2016 to 2020, inclusive.
0 15 10 ? * 5#3 * | Fire at 10:15 am on the 3rd Friday of every month.
0 0 * * * ? * | Fire every hour, every day.

˄˅