Skip to main content

Creating Cron tasks

Cron tasks run repeatedly on a specified cron schedule. Define the task that the automation submits, then register its implementation with a runner.

Registering a cron trigger

After implementing a cron task, register it with one or more schedules. The Python SDK provides a registration helper, and you can also register cron automations from the Tilebox Console. Each matching schedule submits a new job containing one task instance derived from the cron task prototype.
Python
Use crontab.guru to check standard five-field expressions. Remove any CRON_TZ=... prefix before entering an expression there.

Cron schedule syntax

Cron triggers accept standard five-field expressions. The fields specify the minute, hour, day of the month, month, and day of the week in that order.
Use * for every value, , for a list, - for a range, and / for a step. For example, */15 * * * * runs every 15 minutes, while 0 9-17 * * 1-5 runs hourly from 09:00 through 17:00 on weekdays. If both day of month and day of week contain specific values, a trigger runs when either field matches. For example, 0 9 1 * MON runs at 09:00 on the first day of every month and on every Monday. Schedules without an explicit timezone use UTC. Prefix a schedule with CRON_TZ=<timezone> to interpret it in an IANA timezone:
This expression runs at 09:00 Vienna local time on weekdays. The corresponding UTC time changes automatically when Vienna enters or leaves daylight saving time.
Timezone schedules follow traditional cron behavior during daylight saving transitions. A local time skipped when clocks move forward does not trigger. A local time that occurs twice when clocks move backward triggers twice.

Schedule helpers

You can replace a five-field expression with one of these helpers. Helpers use UTC unless you add a CRON_TZ prefix. Timezone prefixes also work with helpers:
This schedule runs every day at midnight in Vienna.

Schedule examples

Starting a cron runner

Cron tasks run on any regular runner that has the task registered. Keep at least one such runner available to execute jobs submitted by the automation.
Python
If this runner runs continuously, its logs may resemble the following:
Logs

Inspecting in the Console

The Tilebox Console provides a straightforward way to inspect all registered Cron automations.
Tilebox Workflows automations in the Tilebox Console
Use the console to view, edit, and delete the registered Cron automations. You can also inspect registered cron triggers from the SDKs.

Deleting Cron automations

To delete a registered Cron automation from Python, use automations.delete. You can also delete cron automations from the Tilebox Console. After deletion, no new jobs will be submitted by that Cron trigger. Past jobs already triggered will still remain queued.
Python

Submitting Cron jobs manually

In Python, you can submit Cron tasks as regular tasks for testing purposes or as part of a larger workflow. To do so, instantiate the task with a specific trigger time using the once method.
Submitting a job with a Cron task using once immediately schedules the task, and a runner may pick it up and execute it. The trigger time set in the once method does not influence the execution time; it only sets the self.trigger.time attribute for the Cron task.
Python