CLI

Sentry Crons allows you to monitor the uptime and performance of any scheduled, recurring job. Once implemented, it'll allow you to get alerts and metrics to help you solve errors, detect timeouts, and prevent disruptions to your service.

To begin monitoring your recurring, scheduled job:

The Sentry CLI uses your Monitor's project DSN to authorize check-ins. To set it up, export the SENTRY_DSN environment variable:

Copied
export SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0

Alternatively, you can add it to your ~/.sentryclirc config:

~/.sentryclirc
Copied
[auth]
dsn = https://examplePublicKey@o0.ingest.sentry.io/0

Learn more about the CLI's configuration file.

Use the Sentry CLI to run your job and notify you if it doesn't start when expected (missed) or if it exceeded its maximum runtime (failed).

Copied
sentry-cli monitors run <monitor_slug> -- <command> <args>

Usage examples:

Copied
sentry-cli monitors run my-monitor-slug -- python path/to/file.py

You can also use the Sentry CLI to create or update your cron monitor when you run your job. This way, you can avoid having to first set up the monitor through the Sentry web interface.

Configure the cron monitor by providing the cron schdule in crontab format using the --schedule or the equivalent -s argument when executing the sentry cli monitors run command. Please make sure to enclose the schedule in quotes, so that your shell parses the argument correctly, like so:

Copied
sentry-cli monitors run --schedule "<expected schedule>" <monitor-slug> -- <command> <args>

When providing the --schedule argument, we also support the following optional arguments to provide additional configuration:

  • --check-in-margin: The allowed margin of minutes after the expected check-in time that the monitor will not be considered missed for.
  • --max-runtime: The allowed duration in minutes that the monitor may be in progress for before being considered failed due to timeout.
  • --timezone: A valid tz database identifier string (e.g. "Europe/Vienna") representing the monitor's execution schedule's timezone.

Below are some usage examples:

Copied
sentry-cli monitors run -s "* * * * *" -- my-command

If your cron monitor runs in multiple environments you can use the -e flag to specify which Monitor Environment to send check-ins to.

Copied
sentry-cli monitors run -e dev my-monitor-slug -- node path/to/file.js
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").