Cron job notifications

If you are looking for a simple one-ping implementation to receive notifications based on whether your job has or hasn't run, you can create a heartbeat monitor instead of the more specific cron job monitor.

  1. From your dashboard, click the button to create a new monitor and select Heartbeat
  2. Add a rule. For example, to be alerted whenever your job completes successfully, add the rule has completed. To be alerted if your job has not completed at least once in the last hour, add complete endpoint not pinged in 1 hour. Multiple rules can be added and will be combined with an implied OR
  3. Add at least one notification method across Email, SMS, Slack, Hipchat, PagerDuty, etc
  4. Give the monitor a descriptive name like User cache warmer and add optional tags or notes
  5. Save the monitor and add the unique ping url provided to your Crontab or code. See the integration guide for details. If your rules reference a /run ping, you should ping the /run endpoint before your job, and if your rules reference /complete you should ping the /complete endpoint after your job.

Using Run and Complete Notifications

Has Run and Has Completed rules provide an easy, modern alternative to crontab emails. These rules can be used to share the status and optional ?msg of a job to Slack, HipChat, Email, SMS, etc. Notification rules are useful on their own or combined with other rule types as a building blocks of your monitoring plan.

  • High visibility. For some jobs the best monitoring option may be "has run" and "has completed" notifications every time your job runs.
  • Keeping an audit log. Cronitor notifications when jobs run or complete can serve as an audit log of job activity.
  • Triggering another job. Use a webhook callback that will kick off another job, workflow or report in response to another job completing. Cronitor as event bus.

Troubleshooting Notification Rules

  • If you receive unexpected alerts for a new monitor, review your ping history from the dashboard to ensure it matches your expectations. If there are missing pings, double check your integration. Verify that you are pinging the /run endpoint before your job and your /complete endpoint after. A missing or misplaced /run or /complete ping is the most common integration mistake.
  • If you've verified that you're pinging /run and /complete appropriately, try changing the logic in your commands from && "and" logic to ; "or" logic.

    Switch from only pinging /complete if your command finishes successfully:

    * */2 * * * curl -m 10 ; /path/to/ && curl -m 10

    To always pinging your /complete URL:

    * */2 * * * curl -m 10 ; /path/to/ ; curl -m 10

    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.