DEV Community

Jack
Jack

Posted on

I Built a Cron Job Monitoring API in a Weekend

Every developer has at least one cron job running somewhere — backups, data processing, sending reports. And every developer has had the experience of discovering a cron job stopped running days (or weeks) ago.

The issue: cron doesn't notify you about failures by default. Your 0 2 * * * /opt/backup.sh could silently fail for a month before someone notices.

The Solution

I built CronPing, a lightweight API for monitoring cron jobs:

  1. Sign up — get an API key
  2. Create a monitor — specify the expected interval
  3. Add a ping to your cron job: && curl -s https://cronping.anethoth.com/ping/YOUR_TOKEN
  4. Get alerted via webhook when a job misses its schedule

Example

# Before (silent failure)
0 2 * * * /opt/backup.sh

# After (monitored)
0 2 * * * /opt/backup.sh && curl -s https://cronping.anethoth.com/ping/abc123
Enter fullscreen mode Exit fullscreen mode

API Design

# Sign up
curl -X POST https://cronping.anethoth.com/api/v1/signup \
  -H "Content-Type: application/json" \
  -d '{ "email": "you@example.com" }' 

# Create a monitor
curl -X POST https://cronping.anethoth.com/api/v1/monitors \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "nightly-backup", "interval_seconds": 86400, "grace_seconds": 300 }' 
Enter fullscreen mode Exit fullscreen mode

Tech Stack

  • FastAPI for the API
  • SQLite for storage
  • Background task that checks for overdue monitors
  • Docker for deployment

Free tier: 3 monitors with 7-day history. Check it out at cronping.anethoth.com.

Top comments (0)