Webtask

Documentation

Cron webtasks

Attach schedules to webtasks

For customized documentation and ready to run samples, please log in.

Overview

Webtask cron jobs are instructions for the webtask cluster to run a webtask periodically according to a supplied schedule. Cron jobs collect the timing details and results of the last 100 scheduled runs of the underlying webtask. The cron job will run the webtask via POST with a payload corresponding to the cron job record in json format.

Cron schedules support the 5-segment syntax: MINUTE HOUR DAY MONTH WEEKDAY. Some examples of this syntax are:

  • To execute at 00:05 every day in August: 5 0 * 8 *
  • To excute at 14:15 on the 1st of every month: 15 14 1 * *
  • To execute at 22:00 on Monday, Tuesday, Wednesday, Thursday and Friday: 0 22 * * 1-5

Note that * maps to any value, and - is used to indicate a range of values. Remember that you can always use a cron schedule expression editor to make your life a bit easier when you have to create a cron string. We find the crontab.guru site useful for this.

Manage cron

You have several options available in order to create and manage a cron job:

  • Webtask CLI: You can use the wt cron command to schedule a webtask to run periodically, list your scheduled webtasks, get information about a scheduled webtask, remove a scheduled webtask, or review your cron job history. For more information refer to the Webtask CLI document or use the built-in help of the tool (command: wt cron -h).
  • Webtask widget: You can use the widget to list, create or edit cron jobs. For more information refer to the Webtask Widget document or the GitHub project documentation.
  • Sandboxjs: A node.js library that simplifies the interaction with a webtask cluster. You can use it to create or remove cron jobs, refresh a job's metadata, get its history and more. You can find a listing of the available methods on the GitHub project documentation and more information on the widget on the Sandboxjs document.

Metadata

Metadata is an arbitrary set of string key / value pairs that are used to describe a webtask, token or cron job. You can associate metadata with cron jobs and query cron jobs based on this metadata:

  • wt cron schedule --meta KEY=VALUE: Use this command to associate metadata with a cron job.
  • wt cron ls --meta KEY=VALUE: Use this command to filter the CRON jobs to be listed based on metadata values. Only scheduled webtasks with matching metadata will be returned.