# Using Cron Expressions

> Cron is a software utility, present in Unix-like operating systems, used for time-based scheduling. It provides for highly customizable scheduling of recurring tasks using a string of 6 (or 7, when including year) fields separated by white space. The format of the string is `seconds` `minutes` `hours` `day of the month` `month` `day of the week` `year`.

Cron is a software utility, present in Unix-like operating systems, used for time-based scheduling. It provides for highly customizable scheduling of recurring tasks using a string of 6 (or 7, when including year) fields separated by white space. The format of the string is `seconds` `minutes` `hours` `day of the month` `month` `day of the week` `year`.

In Orchestrator, cron expressions are based on an internal scheduling library that uses background tasks, and are used when creating a Time Trigger using the **Advanced** scheduling option:

Figure 1. Advanced scheduling option

![Screenshot of the advanced scheduling option page](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-screenshot-of-the-advanced-scheduling-option-page-226122-db82c507.webp)

Each field in a cron expression has a specified range of values and special characters that may be used in creating the schedule, as detailed below:

| Field | Mandatory | Allowed Values | Allowed Special Characters |
| --- | --- | --- | --- |
| `seconds` | Yes | `0` - `59` | `,` `-` `*` `/` |
| `minutes` | Yes | `0` - `59` | `,` `-` `*` `/` |
| `hours` | Yes | `0` - `23` | `,` `-` `*` `/` |
| `day of the month` | Yes | `1` - `31` | `,` `-` `*` `/` `?` `L` `W` |
| `month` | Yes | `1` - `12` or `JAN` - `DEC` | `,` `-` `*` `/` |
| `day of the week` | Yes | `1` - `7` or `SUN` - `SAT` | `,` `-` `*` `/` `?` `L` `#` |
| `year` | No | blank or `1970` - `2099` | `,` `-` `*` `/` |

The meanings and usage of the available special characters are as follows:

| Character | Description | Example |
| --- | --- | --- |
| `*` | Used to indicate all values for the given field. | `*` `*` `*` `?` `*` `*` would trigger every second, whereas `0` `*` `*` `?` `*` `*` would trigger every minute, more specifically at second 0 of each minute. |
| `?` | Used to indicate that no value is specified. May be used only in the `day of the month` or `day of the week` fields. | `0` `0` `0` `15` `*` `?` `*` would trigger at midnight on the 15th day of each month, whereas `0` `0` `0` `?` `*` `2` `*` would trigger at midnight each Monday. |
| `-` | Used to indicate a range of values. | `0` `0` `9-17` `?` `*` `2-6` would trigger every hour from 9:00am until 5:00pm on Monday through Friday. |
| `,` | Used to indicate additional values. | `0` `0` `9-17` `?` `*` `MON,WED,FRI` would trigger every hour from 9:00am until 5:00pm on Mondays, Wednesdays, and Fridays. |
| `/` | Used to indicate increments of the given field(s). | `0` `0` `0/3` `?` `*` `2/7` would trigger every three hours, on Mondays, beginning at midnight. |
| `L` | Used to indicate Last. May be used only in the `day of the month` or `day of the week` fields. For `day of the week`, it can be used after another value, for example `6L` to indicate the last Friday. | `59` `59` `23` `L` `*` `?` would trigger at 11:59:59pm on the last day of each month, whereas `59` `59` `23` `?` `*` `6L` would trigger at the same time but only on the last Friday of each month. |
| `W` | Used to indicate the nearest weekday to the given value. May only be used with the `day of the month` field. | `0` `0` `0` `15W` `*` `?` would trigger at midnight of the nearest weekday to the 15th, every month. If the 15th is a Saturday, it would trigger on Friday the 14th, whereas if the 15th is Sunday, it will trigger on Monday the 16th. |
| `#` | Used to indicate a desired monthly occurrence of the given value, for example the first Friday, or fourth Thursday. May only be used with the `day of the week` field. | `0` `0` `17` `?` `*` `6#1` would trigger at 5:00pm on the first Friday of every month. |

## Examples

The following table shows common scheduling expressions. Because the `day of the week` field uses `1` for Sunday through `7` for Saturday, expressions such as `2-6` for Monday–Friday differ from implementations where Sunday is `0`.

| Expression | Description |
| --- | --- |
| `0 0 12 ? * *` | Every day at noon |
| `0 30 8 ? * 2-6` | Every weekday (Mon–Fri) at 8:30 AM |
| `0 0 9,17 ? * 2-6` | Every weekday at 9:00 AM and 5:00 PM |
| `0 0,30 10-18 ? * 2-6` | Every 30 minutes from 10:00 AM to 6:30 PM, Monday through Friday |
| `0 0/15 * ? * *` | Every 15 minutes, around the clock |
| `0 0 0/6 ? * *` | Every 6 hours starting at midnight (midnight, 6:00 AM, noon, 6:00 PM) |
| `0 0 9 ? * 2` | Every Monday at 9:00 AM |
| `0 0 8 1 * ?` | First day of every month at 8:00 AM |
| `0 0 0 L * ?` | Last day of every month at midnight |
| `0 0 17 ? * 6#1` | First Friday of every month at 5:00 PM |
