Monitoring Cron and Scheduled Tasks With Healthchecks.io

Keeping an eye on web servers that stop serving pages or hard drive that fill up are monitoring basics. Check for a state, do a little computation, or check a threshold is pretty simple to understand. Most monitoring applications give you the ability to make sure a Scheduled Tasks returns a zero exit code, but what happens when the task never runs? You want to monitor the lack of an event. This is where Healthchecks.io comes into play.

I found HealthChecks.io while recovering from a personal data loss. My backups hadn’t run in months and while the data wasn’t important, it was tedious to restore everything back to working order. What I needed was a dead man’s switch. Lesson learned.

Configure

To add a check, click the big green button. You’ll be greeted with a screen to configure your check. Give it a good name. This is part of the notification you’ll receive.

HealthChecks.io

Healthcheck gives you examples to get you started. Pretty much any language you’d want to start from.

Examples in various programming languages

They offer tons of integrations so you can connect your favorite apps up to receive the alerts. You can even hook it up to OpsGenie or PagerDuty as part of an on-call rotation. I’m partial to Pushover.

List of integrations

You can time the duration of a job if you use the /start endpoint at the beginning of your script.

The free plan gives you a generous 20 checks. They offer a self-hosting option. This should allow you to keep track of your cron jobs or automated tasks. I use it to make sure my hugo blog is completely rebuilt on a weekly basis. The possibilities are endless.