What are the differences between Time Interval and Cron Expression?
- Last updated
- Save as PDF
Last Updated: | Applicable Hub Versions: 20.1 and later
Answer
Time Interval
Time interval is a fundamental case, which means that changes will continue polling until Hub is stopped or restarted. Time interval is most effective for configuring simple change detection or full scan jobs.
Hub's default global change detection settings can be found on the Settings screen.
Time Interval Example
Here's an example of how time interval works:
Configured Intervals:
- Change Detection:
- Time Interval: 5 seconds
- Full Scan:
- Time Interval: 15 seconds
In this example, you can see that regardless of how long a change detection or full scan job takes, Hub will wait either 5 seconds or 15 seconds before starting the next job. However, if there is a full scan or change detection job already running during the pre-configured intervals (e.g., 5 seconds or 15 seconds), the subsequent job will run at the next available time. These pre-configured intervals will NOT trigger until the job completes.
Cron Expression
Cron expression allows you to configure complex schedules such as scheduling change detection or full scan to only run during certain hours of the day, week, or month. Cron expression allows for much more advanced schedules compared to time interval.
You can learn more about how to configure your change detection or full scan job with cron expression here.
Cron Expression Example
Here's an example of how cron expression works:
Configured Intervals:
- Change Detection:
- Cron Expression: 0/5 0 0 ? * * *
- Definition: Every 5 seconds starting at second :00.
- Full Scan:
- Cron Expression: 0/15 0 0 ? * * *
- Definition: Every 15 seconds starting at second :00.
In this example, you can see that cron expression has scheduled change detection jobs to run every 5 seconds starting at second :00 and full scan jobs to run every 15 seconds starting at second :00. At second :15, a scheduled change detection job is expected to run, however, because there is full scan job running at that second, the scheduled change detection job runs as soon as the full scan job completes.
Writing Cron Expressions
Note: Cron expressions must be written using the Quartz cron format to be valid.
-
If a user would like to run full scan every 30 minutes within business hours (9am-5pm) from Monday through Friday, it would be written as follows:
-
*0 0/30 9-16 ? * MON-FRI*
-
Definition: Every 30 minutes, between 09:00 AM and 04:59 PM, Monday through Friday.
-
Example scheduled execution dates:
-
Tue Dec 24 09:00:00 2019
-
Tue Dec 24 09:30:00 2019
-
Tue Dec 24 10:00:00 2019
-
-
-
- If you would like to run full scan every 30 minutes outside of business hours from 5pm to 9pm on Saturday and Sunday, it would be written as follows:
-
*0 0/30 17-20 ? * SUN,SAT*
-
Definition: Every 30 minutes, between 05:00 PM and 08:59 PM, only on Sunday and Saturday.
-
Example scheduled execution dates:
-
Sat Dec 28 17:00:00 2019
-
Sat Dec 28 17:30:00 2019
-
Sat Dec 28 18:00:00 2019
-
-
-
Why isn't my Cron Expression working?
Possible Causes:
- Your cron expression is not valid.
- Hub has a limitation in our readable cron expression that may cause inaccuracies because we are using a third party library. It is best to validate the readable cron expression on a quartz cron website.
- Too many integrations are currently running, and your machine specs may be outdated.
- As the number of running integrations limits the number of threads, we have to wait for available threads for change detection to work.
- A previous change detection or full scan job may have taken longer than expected.
- This may have coincided with your next scheduled full scan, and it will affect your next scheduled cron change detection or full scan.
Time Interval and Cron Expression
Here is an example of time interval and cron expression working simultaneously:
Configured Intervals:
- Change Detection:
- Time Interval: 5 seconds
- Full Scan:
- Cron Expression: 0/15 0 0 ? * * *
- Definition: Every 15 seconds starting at second :00.
In this example, the user has configured change detection to run at a time interval of 5 seconds and full scan to run at a schedule of every 15 seconds starting at second :00. As you can see, at second :17 a change detection job is expected to run, however, because cron expression has scheduled a full scan job to run during that second, the next change detection job begins at second :21.
Note: For both cron expression and time interval, we advise against configuring small intervals as they put an additional load on the end repositories and can be much less effective.
How do manually requested scans work with Time Interval and Cron Expression?
Manually requested full scans are scans that a user can force by clicking the 'Process All Artifacts' button on the Field Flow screen or 'Initiate Synchronization' on the Artifact Filtering screen. Requested full scans have a higher priority than all other types of scans. Requested full scans that cannot run at the specified time (e.g., because a current job is already running), will run immediately when the current job finishes.
You can learn more about requested scans here.
Here is an example of how requested full scans work:
Configured Intervals:
- Change Detection:
- Time Interval: 5 seconds
- Full Scan:
- Cron Expression: 0/15 0 0 ? * * *
- Definition: Every 15 seconds starting at second :00.
In this example, the user requested a full scan at second :03, however, because there was a change detection job running at that second, the requested full scan began after the change detection job was completed.