Skip to content

Cron trigger

The workflows created in Mistral can be launched following an specified schedule (for example, every Sunday at 4.00pm)

Cron trigger is an object allowing to run workflow on a schedule. User specifies what workflow with what input needs to be run and also specifies how often it should be run. Cron-pattern is used to describe the frequency of execution in Mistral. To see more about cron-patterns, refer to Cron expression

Create a cron trigger

As a prerequisite, you need to have a workflow defined previously, we'll use as an example the one defined in the quickstart guide

In this example we are creating a trigger that runs every day at 2:00am

$ openstack cron trigger create --pattern '0 2 * * *' first_cron_trigger echo '{"data":"my first cron trigger"}'
+----------------------+---------------------+
| Field                | Value               |
+----------------------+---------------------+
| Name                 | first_cron_trigger  |
| Workflow             | echo                |
| Params               | {}                  |
| Pattern              | 0 2 * * *           |
| Next execution time  | 2018-02-16 02:00:00 |
| Remaining executions | None                |
| Created at           | 2018-02-15 13:47:05 |
| Updated at           | None                |
+----------------------+---------------------+

On the cron creation you can also specify the first-time of the first execution and a maximum number of executions after it gets disabled You can see all the possible options of the command using the -h parameter

List cron triggers

You can see the available cron triggers by executing

$ openstack cron trigger list
+--------------------+----------+--------+-----------+---------------------+----------------------+---------------------+------------+
| Name               | Workflow | Params | Pattern   | Next execution time | Remaining executions | Created at          | Updated at |
+--------------------+----------+--------+-----------+---------------------+----------------------+---------------------+------------+
| first_cron_trigger | echo     | {}     | 0 2 * * * | 2018-02-16 02:00:00 | None                 | 2018-02-15 13:47:05 | None       |
+--------------------+----------+--------+-----------+---------------------+----------------------+---------------------+------------+

This list will get updated once the execution has been triggered and you can see the result of the execution on the 'openstack workflow execution list' command

Delete cron trigger

You can delete the cron trigger by running:

$ openstack cron trigger delete first_cron_trigger
Request to delete cron trigger first_cron_trigger has been accepted.