Monitor robfig/cron Scheduled Jobs in Go

Go

The Problem

Using robfig/cron for in-process scheduling means failures are hidden inside the running process. No external system knows if your job actually executed.

The Solution

Add CronRabbit pings inside your cron function handlers. Each scheduled function gets its own monitor for independent alerting.

In-Process vs System Cron

robfig/cron runs inside your Go application process. If the process crashes, all scheduled jobs stop. CronRabbit detects this because the expected pings stop arriving.

Per-Job Monitoring

Create a separate CronRabbit monitor for each scheduled function. This gives you independent alerting and duration tracking per job.

Code Examples

robfig/cron with per-job monitoring

Go
package main

import (
	"net/http"
	"time"
	"github.com/robfig/cron/v3"
)

var client = &http.Client{Timeout: 10 * time.Second}

func main() {
	c := cron.New()
	c.AddFunc("0 2 * * *", func() {
		client.Get("https://ping.cronrabbit.com/backup-id/start")
		if err := runBackup(); err != nil {
			client.Get("https://ping.cronrabbit.com/backup-id/fail")
			return
		}
		client.Get("https://ping.cronrabbit.com/backup-id")
	})
	c.Start()
	select {}
}

Ready to Monitor Your Cron Jobs?

Create your free account and add your first monitor in under 5 minutes. No credit card required.