With Cronitor you can create and integrate a cron job monitor in minutes, no coding required. When you create a monitor using a cron schedule like
*/15 * * * 1-5
we will alert you if your job does not run successfully, including:
If you are monitoring jobs in a crontab file, using
cronitor discover in CronitorCLI is
the easiest way to automatically create monitors for each job and keep their schedule in sync with your server.
discoverfor the first time your API key is required. Use
cronitor configure -k <API KEY>to save the key in the system-wide cronitor config file, or see the "Configuration" section of Using CronitorCLI for more configuration options.
cronitor discover <CRONTAB PATH>to read the crontab file and automatically create monitors for each entry using the Cronitor API. Your crontab will be rewritten to include necessary
cronitor execcalls when each job runs and the updated crontab will be written to stdout.
cronitor discoveryou will see the newly discovered cron jobs on your dashboard. Monitor names are created from the command being run. Names can be updated manually from the dashboard or you can re-run
cronitor discoverwith optional
-e, --exclude-from-nameargument(s) to remove path names and other boilerplate from the automatically generated name. Re-run
cronitor discoveras many times as needed until the names on your dashboard are acceptable. Note that name length is limited to 100 chars. See
cronitor help discoverfor examples.
cronitor discoverhas imported your crontab, and after reviewing the stdout output for accuracy, complete the integration by updating your crontab file with the output from the
discovercommand. Note: If you are not using
crontab -eto update contents you may need to restart your cron daemon to pick up changes to the crontab file.
cronitor discover adds itself as an entry to each crontab file. This feature, auto-discover, is used to push schedule changes to Cronitor and alert
you to any new jobs that have been added without monitoring.
If you are monitoring jobs that use cron-like scheduling without a crontab file, you can manually create and integrate a cron monitor with just a few steps.
Your new monitor is created in a paused state; monitoring will not begin until the first ping is received.
It's great to know that your cron job started but it's really valuable to know that it completed successfully. To alert you as quickly as possible when that's not the case we've developed a duration prediction algorithm. The predictions grow more accurate as we learn more about your job performance but will not work perfectly for every job. If it's normal for job runtime to vary significantly, or if you are receiving has not completed alerts earlier than you would like, you can provide a fixed runtime duration:
To send duration alerts, Cronitor must know when your job starts running and when it completes successfully. To
report these events, you should ping your
/run endpoint as your job starts and
as it exits successfully. For more details on ping URL endpoints and where you should integrate your ping requests,
grace_secondson your not_on_schedule rule.
/runendpoint before your job and your
/completeendpoint after. A missing or misplaced
/completeping is the most common integration mistake.
datecommand on your linux server or
tzutil /gon windows you can verify that your server time matches the timezone set in your account settings.
If you've verified that you're pinging
/complete endpoints appropriately, try changing the logic in your
&& "and" logic to
; "or" logic.
Switch from only pinging
/complete if your command finishes successfully:
* */2 * * * curl -m 10 https://cronitor.link/d3x0/run ; /path/to/db_backup.sh && curl -m 10 https://cronitor.link/d3x0/complete
To always pinging your
* */2 * * * curl -m 10 https://cronitor.link/d3x0/run ; /path/to/db_backup.sh ; curl -m 10 https://cronitor.link/d3x0/complete
By changing to
; you will ping your Cronitor URL even if your command exits with a non-zero
exit code. If this works, you should investigate why your command is exiting with an error code.