Cron Jobs

Currently, Cron Jobs are an experimental feature and not recommended for production use. The api is actively being worked on and may change at any time.

Cron jobs can be used to periodically perform an HTTP request to your production Globe deployment. You can specify the cron schedule and the path to request.

Cron jobs only work with production deployments. If your project does not have a production deployment, the cron execution will be ignored and no events will be shown.

Creating a Cron Job#

Cron jobs can be created via the globe.yaml file in the root of your application project, for example:

  - id: refresh_auth_token
    schedule: '*/45 * * * *'
    path: '/auth/refresh'

In the above example, the cron job will be executed every 45 minutes. For more details on cron code, see the unix-cron documentation.

Whenever a new production deployment is successful, the cron jobs will be synchronized and shown in the dashboard.

Handling Cron Jobs#

Your application code should handle the cron job request via the path specified (/auth/refresh in the above example). The request will be a POST request.

For example, using shelf_router this can be achieved as follows:

import 'package:shelf_router/shelf_router.dart';

var app = Router();'/auth/refresh', (Request request) async {
  // Some logic to refresh the auth token
  return Response.ok('ok');

If a Cron Job returns a response with a status code other than one in the 2xx range, this will show on the dashboard as an error.

Cron Job IDs#

The id field in the list represents the unique ID of the cron job. This is used to identify the cron job on the dashboard, and store event logs. If a specific ID is removed, and later added, new event logs will be stored alongside any previous logs. Also note:

  • The list cannot contain duplicate IDs.
  • The maximum length of an ID is 50 characters.
  • The ID can only contain lowercase letters, numbers, and underscores (a-z0-9_).


At present, all cron jobs are executed in the UTC (Universal Coordinated Time) timezone, so you must take this into account when specifying the schedule.

Please upvote this feature request if you would like support for custom timezones.