Scheduling
Script tasks and URL watchers run on a schedule. Daemons and plugins don't have one: they run continuously from the moment they're enabled.
You set the schedule in the Add Task or Edit dialog, under Schedule, by choosing either Every N minutes or Cron.
Every N minutes
The task runs at a fixed interval, at least one minute. The default is 5 minutes.
The first run comes one interval after the task is enabled (or after the hub starts), not straight away. Press Run now on the task card if you want a run immediately.
Cron
A cron schedule is a standard five-field crontab expression:
minute hour day-of-month month day-of-week
| Field | Values |
|---|---|
| minute | 0 to 59 |
| hour | 0 to 23 |
| day of month | 1 to 31 |
| month | 1 to 12, or jan to dec |
| day of week | 0 to 7, or sun to sat |
Each field accepts * (every value), a single value, a range such as 9-17, a list such as 1,15, and a step such as */15.
Times are in the hub PC's local time zone.
Days of the week follow the usual cron numbering: 0 and 7 are Sunday, 1 is Monday, and 6 is Saturday. So 1-5 and mon-fri both mean Monday to Friday.
| Expression | Runs |
|---|---|
0 2 * * * | Every day at 02:00. |
*/15 * * * * | Every 15 minutes, on the quarter hour. |
0 9 * * 1-5 | At 09:00 on weekdays. |
30 18 * * sun | At 18:30 on Sundays. |
0 8 1 * * | At 08:00 on the first day of each month. |
0 */6 * * * | Every six hours, on the hour. |
Things to know
- Runs only happen while the hub is running. Runs missed while it was stopped aren't made up when it starts again.
- If a scheduled run is still going when the next one is due, that next run is skipped. Run now doesn't wait, so pressing it during a run starts a second run alongside the first.
- Run now runs the task straight away and doesn't change its schedule.
- Disabling a task removes it from the schedule; enabling it puts it back.
In the API
The schedule field of a task takes one of these shapes:
{ "type": "interval", "minutes": 30 }
{ "type": "cron", "cron": "0 9 * * mon-fri" }
When a script or URL watcher is created without a schedule, it runs every 5 minutes. A cron schedule with a missing or invalid expression is rejected with a 422. For daemons and plugins the hub always stores null. See Tasks.