Cron-based Schedulers
A cron expression is a string that precisely specifies when your automation should run, down to the second. It consists of multiple time-based fields arranged in a specific order, enabling you to define flexible schedules such as “every Monday at 9 AM” or “every 10 minutes.” This string follows the standard UNIX cron syntax used widely for task scheduling.
Unlike basic schedulers, cron expressions allow for advanced scheduling, letting you run automation tasks at exact intervals—hourly, daily, weekly, or according to complex patterns. This level of control is particularly useful for automating repetitive and time-sensitive tasks consistently over time.
Common uses of cron-based scheduling include:
1. Running scheduled reports
2. Performing regular backups
3. Sending periodic email notifications
4. Executing system maintenance tasks
How Cron Expressions Work
A cron expression is made up of six mandatory fields and one optional field, each representing a unit of time:
Seconds | Minutes | Hours | Day of Month | Month | Day of Week | [Year – optional]
Field | Position | Mandatory | Allowed values | Special characters supported |
---|---|---|---|---|
Second | 1st | Yes | 0–59 | * , - / |
Minute | 2nd | Yes | 0–59 | * , - / |
Hour | 3rd | Yes | 0–23 | * , - / |
Day of Month | 4th | Yes | 1–31 | * , - / ? L W |
Month | 5th | Yes | 1–12 or JAN–DEC | * , - / |
Day of Week | 6th | Yes | 0–6 or SUN–SAT | * , - / ? L # |
Year (optional) | 7th | No | 1970–2099 | * , - / |
Special Character Usage
Character | Usage |
---|---|
* | Every possible value (e.g., every second) |
, | Multiple values (e.g., MON, WED, FRI) |
- | Range (e.g., 1-5 means 1 through 5) |
/ | Step values (e.g., 0/15 = every 15 seconds/minutes) |
? | No specific value (used in Day of Month or Day of Week to avoid conflict) |
L | Last (e.g., L = last day of month or last weekday) |
W | Nearest weekday (e.g., 15W = weekday near the 15th) |
# | Nth weekday of the month (e.g., 2#1 = first Monday) |
Important
1. In Quartz cron expressions, both the day-of-month and day-of-week fields cannot be set to ‘*’ at the same time. One of them must be set to ‘?’ to indicate that it should be ignored for scheduling purposes.
2. The ‘?’ character can only be used in either the day-of-month or day-of-week field, not in others.
3. Day-of-week values must be specified using three-letter abbreviations (SUN–SAT)
Examples
Cron Expression | Description |
---|---|
0 0 9 * * ? | Runs every day at 9:00 AM |
0 30 18 * * ? | Runs every day at 6:30 PM |
0 0/10 * * * ? | Runs every 10 minutes, all day long |
0 0 12 ? * MON-FRI | Runs every weekday (Monday to Friday) at 12:00 PM |
0 15 10 ? * 2#1 | Runs on the first Monday of every month at 10:15 AM |
0 0 8 15W * ? | Runs on the nearest weekday to the 15th of each month at 8:00 AM |
0 0 6 ? * SUN | Runs every Sunday at 6:00 AM |
0 0 23 L * ? | Runs on the last day of every month at 11:00 PM |
0 0 1 ? * 5L | Runs on the last Thursday of every month at 1:00 AM |
0 0/5 9-17 * * MON-FRI | Runs every 5 minutes between 9 AM and 5 PM, Monday to Friday |
0 0 9 1 1 ? 2025 | Runs once on January 1, 2025 at 9:00 AM |
0 0/15 * * * ? | Runs every 15 minutes, throughout the day |
0 0 0 ? * 7#2 | Runs on the second Sunday of every month at 12:00 AM (midnight) |
Common Cron Expressions
Expression | Meaning |
---|---|
0 0 * * * ? * | Every hour |
0 0 0 * * ? * | Every day at 12:00 AM |
0 30 9 * * ? * | Every day at 9:30 AM |
0 0/30 * 1/1 * ? * | Every 30 minutes |
0 0 12 ? * WED * | Every Wednesday at 12 PM |
0 0 12 L * ? * | At 12 PM on the last day of month |
Each field accepts specific values and special characters to define complex schedules, such as ranges, intervals, and wildcards. For example, the “?” character means “no specific value,” useful to avoid conflicts between Day of Month and Day of Week fields.
Setting a Cron Expression in Robility Manager
To create a cron-based schedule:
1. Navigate to your project in the tenant.
2. Confirm a resource is added in the “Deploy Robots” page.
3. Go to the “Schedule Robots” page.
4. Click “Add” and enter a scheduler name.
5. Select the machine and choose “Advanced” frequency.
6. Complete the required details.
7. Enter your cron expression in the Manual Cron Expression section.
8. A human-readable interpretation of your cron expression will be displayed.
9. Click Save to finalize the scheduler.
Tips
1. Choose basic scheduling for simple daily/weekly triggers.
2. Use advanced cron scheduling for detailed control like “every 15 minutes between 9 AM and 5 PM” or “the last Friday of every month.”
3. Invalid cron expressions will show an “Invalid Cron expression format” message