Scheduling a Job Using REST API
On This Page
- 1 Overview
- 2 Additional Auto Scheduling Options
- 3 Examples
- 3.1 Example 1: Defined Days with Start and End Windows
- 3.2 Example 2: Max Executions
- 3.3 Example 3: Run at a Specific Time
- 3.4 Example 4: Run on a Specific Date at a Specific Time
- 3.5 Example 5: Run Every 15 Minutes Indefinitely
- 3.6 Example 6: Run Every 5 Minutes Indefinitely
- 3.7 Example 7: Run Hourly Everyday Within a Time Frame
- 3.8 Example 8: Run Everyday, Every Hour, Within a Specified Time Frame for a Given Date Range
- 3.9 Example 9: Full Job Creation Block
- 4 Convention Job Schedules
- 5 Clearing Job Settings
- 6 Scheduling Multiple Jobs | Job Queue
Overview
A job schedule allows you to control when the job runs. The schedule manages the job runs for you so you don't have to manually execute job runs. The schedule can be set to determine both how often a job runs and when a job should stop running (also called the job stop policy). You also have the option of editing schedules for jobs, too. When defining the mode of your job, you have the following options.
Mode | Description | Code |
---|---|---|
ad-hoc | The job will not run until manually triggered. The job status will be "completed" when the job finishes the run. |
|
auto | The job will be added to the job queue and run when a there is an available spot. The job will then run every 15 minutes after the initial run. |
|
manual | The job will not run until manually triggered. |
|
Additional Auto Scheduling Options
For auto, you can add additional scheduling options to define the job schedule. The table lists the options individually and identifies each option's code formatting. However, options can be used in combination. See the Examples sections for code samples using multiple schedule options.
Option | Description | Values | Code |
---|---|---|---|
days | Sets the day(s) the job should run. | "everyday" "weekdays""weekends""monday" |
|
start_date | Sets the date to start running the job. |
|
|
end_date | Sets the day to stop running the job. |
|
|
repeat_count | Sets the maximum number of times the job runs in one day.
|
|
|
repeat_interval | Sets the time interval, from the last start time, from which to start the next run of the job.
|
|
|
start_window | Sets the time of day to start the job execution.
|
|
|
end_window | Sets the time of day the last job execution should run. This option cannot be used with run_at. Note that a scheduled job will not run if the last run time for the job equals the “end_window” set in the job schedule. For example, if you schedule a job to run every 15 minutes starting at 1:00 PM and ending at 1:30 PM, the job will run at 1:00 PM and then at the scheduled 15-minute increment. If the next run time calculated for the job is 1:30 PM (the same as the “end_window” set for the job), the job will not be run again at 1:30 PM. |
|
|
max_execution | Sets the maximum amount of time the job can run. Once the job hits this maximum, it stops. | Acceptable units are: "d""h""m""ms""ns""s""us" |
|
run_at | Sets the time of day to start the job execution.
|
|
|
Examples
The examples below show how to use the various "auto" options in combination.
Example 1: Defined Days with Start and End Windows
The following example shows a schedule that uses the following options:
Days: Only on weekends
End Date: April 6, 2018 GMT (1523025357 is Unix Epoch format)
Start Window: 8:00 AM GMT
End Window: 8:00 PM GMT
Interval: Every 15 minutes (the default interval will be used since no other interval is included)
"schedule": {
"mode": "auto",
"days": "weekends",
"end_date": "1523025357",
"start_window": {
"hr": 8,
"min": 0,
"sec": 0,
"ms": 0
},
"end_window": {
"hr": 20,
"min": 0,
"sec": 0,
"ms": 0
}
}
Example 2: Max Executions
The following example shows a schedule that uses the following options:
Max Execution: 1 day (The job will stop if the execution is running longer than 1 day.)
Interval: Every 15 minutes (the default interval will be used since no other interval is included)
"schedule": {
"mode": "auto",
"max_execution": {
"unit": "d",
"value": 1
}
}
Example 3: Run at a Specific Time
The following example shows a schedule that uses the following options:
Days: Mondays
Run at: 8:00 AM GMT
Interval: Every 15 minutes (the default interval will be used since no other interval is included)
"schedule": {
"mode": "auto",
"days": "monday",
"run_at": {
"hr": 8,
"min": 0,
"sec": 0,
"ms": 0
}
}
Example 4: Run on a Specific Date at a Specific Time
The following example shows a schedule that uses the following options:
Start Date: April 6, 2018 at 2:35 PM GMT (1523025357 in Unix Epoch format)
Start Window: Each day the job will start running at 8:00 AM GMT and run every 15 minutes thereafter. (See interval below.)
Interval: Every 15 minutes (the default interval will be used since no other interval is included)
Example 5: Run Every 15 Minutes Indefinitely
The following example shows a schedule that uses the following options:
Repeat Interval: Every 15 minutes with no schedule to stop. The next job run will be 15 minutes after the last run has completed.
Example 6: Run Every 5 Minutes Indefinitely
The following example shows a schedule that uses the following options:
Repeat Interval: Every 5 minutes with no schedule to stop. The next job run will be 5 minutes after the last run has completed.
Example 7: Run Hourly Everyday Within a Time Frame
The following example shows a schedule that uses the following options:
Days: Everyday
Repeat Interval: Every hour. The next job run will be 1 hour after the last run has completed.
Start Window: Start at 6:00 AM GMT
End Window: End at 9:00 PM GMT
The job will run indefinitely since no stop schedule is set.
Example 8: Run Everyday, Every Hour, Within a Specified Time Frame for a Given Date Range
The following example shows a schedule that uses the following options:
Days: Everyday
Repeat Interval: Every hour. The next job run will be 1 hour after the last run has completed.
Start Date: August 21, 2019 12:00:00 AM GMT
End Date: August 21, 2020 12:00:00 AM GMT
Start Window: 6:00 AM GMT
End Window: 9:00 PM GMT
Example 9: Full Job Creation Block
This example includes the entire job creation JSON block and all the schedule options.
Convention Job Schedules
The default schedule for a convention job is set to run every 6 hours so it can review the source for any new content. You can edit this schedule as needed using any schedule option preferred. When setting the schedule for convention jobs, you set the schedule for the convention job (parent job) and child jobs separately. This allows the child jobs to run on a different schedule than the convention job. You will use the schedule in the transfer block to set the schedule for child jobs and use the schedule outside of the transfer block to set the schedule for the convention job itself.
In the example below,
The child jobs will use the auto schedule.
The convention job will use the manual schedule.
Clearing Job Settings
Any schedule field can cleared by setting the value to "null" in a call. For fields that have a default value other than "null," clearing the value sets the field back to the default value.
For example, if days is set to "weekdays," you can clear that setting using the "null" value as in the sample code below. The job will now run everyday (the default value).
Scheduling Multiple Jobs | Job Queue
Jobs will run at their next scheduled time assuming there is an available thread.
The default number of concurrent running jobs is six. This can be configured by the performance:concurrent_transfers
configuration parameter. When all available threads are running jobs, jobs will be queued in the order in which they are triggered. For queued jobs, the Next Run on the Job Detail panel will display a time in the past. A job with a Next Run value of 2 minutes ago will start before a job with a value of 1 minute ago.
Anomalies in the job execution order may occur when jobs are queued and the DryvIQ services is stopped and restarted. In this case you may see other jobs started before the previously queued jobs.