Schedule a Job
Sometimes you have a job that you want to run frequently. With AskAnna you can add a schedule to your
askanna.yml configuration. On this page we will tell you how you can create schedules for a job and check the applied schedules for a job in the web interface.
Create a Schedule
In the definition of the job, you can optionally define a schedule:
name of the job: job: - ... schedule: - "@weekly"
Or multiple schedules:
name of the job: job: - ... schedule: - "@weekly" - day: 1 - "0 8 * * *"
In AskAnna we use cron to schedule jobs. Because cron syntax is not always easy to read, we added a couple of templates:
List using cron names
You can add a list with names that refer to the different cron names:
name of the job: job: - ... schedule: - minute: 10 hour: 8 day: "5-10" month: 12 weekday: 1
The list example above translates into a schedule that runs at 08:10 on day-of-month from 5 through 10 and only on Monday.
You don't have to specify every item in the list. If you leave it empty, we will interpret it as
every x. For example, the following definition will run every minute on the first day of the month:
name of the job: job: - ... schedule: - day: 1
We also support the official cron syntax. Cron expressions looks like
* * * * *. The syntax has 5 positions. Each position has it's own value:
|1.||Minute||0 - 59|
|2.||Hour||0 - 23|
|3.||Day (of the month)||1 -13|
|4.||Month||1 - 12|
|5.||Day of the week||0 - 6 (Sunday = 0, Monday = 1, ..., Saterday = 6)|
Supported syntax for Cron (and also for the list using cron names values):
|*||any value, for example |
|,||list seperator, for example |
|-||range of values, for example |
|/||ste value, for example |
To make it easier to define or check a cron schedule, you can use the quick and simple editor for cron schedule expressions: crontab guru
The AskAnna platform runs by default on servers that are configured to run on timezone
UTC. If you want to run a job at a specific time in a timezone of your request, then you can configure this:
name of the job: job: - ... schedule: - hour: 8 timezone: Europe/Amsterdam
For timezones, we use the tz database. In the
askanna.yml config, you can refer to any TZ database name from the list of tz database time zones:
Validate a Schedule
Since version 0.8.0 of the AskAnna CLI, we also support validation of the
askanna.yml. Part of the validation is that we also validate the schedules.
Validation runs the moment you push code to your project in AskAnna. If you have specified an invalid schedule, the AskAnna CLI prints feedback in the terminal, so you know what to fix.
View active Schedules
When a job has a schedule, we also show it on the job page. Here you can find the date-time of the next run. Also, you can find the schedule or a list of schedules:
In the web interface you can check the schedules in a human-friendly format. When you point your mouse on a schedule, you can see the original definition and next run:
Runs triggered by a schedule
If a schedule triggers a run, this information is available. When you request the runinfo in the response, you will see the trigger value set to
SCHEDULE. This information is also shown on the run page:
In AskAnna we check every minute if we should trigger new runs. If somehow, for example a job was not triggered because of a system restart or interruption, we will do a check every 5 minutes if we might have missed to trigger a new run. If that's the case, we will make sure it is triggered on the next schedule.