惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
The Cloudflare Blog
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
C
Check Point Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
F
Fortinet All Blogs
B
Blog
大猫的无限游戏
大猫的无限游戏
N
Netflix TechBlog - Medium
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to Monitor Your Cron Jobs in Production (So They Don'...
Jack · 2026-04-26 · via DEV Community

Jack

How to Monitor Your Cron Jobs in Production (So They Don't Silently Die)

Every production system has cron jobs. Database backups, report generation, cache warming, email digests — the list grows with your product. But here's the thing: cron jobs fail silently.

Your backup script has been failing for 3 weeks? Nobody knows until you need to restore. Your nightly ETL hasn't run since the last deploy? You'll find out when the CEO asks why the dashboard is stale.

The Dead Man's Switch Pattern

The most reliable way to monitor cron jobs is the dead man's switch (or heartbeat) pattern:

  1. Create a monitor with an expected schedule
  2. Your cron job pings the monitor after completing successfully
  3. If the monitor doesn't receive a ping within the expected window, fire an alert

This is fundamentally different from log monitoring because it catches jobs that never start — not just jobs that start and fail.

Implementation

Here's how it works with a simple HTTP endpoint:

# Your existing cron job
0 2 * * * /usr/local/bin/backup.sh

# Add monitoring - ping after success
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://cronping.anethoth.com/ping/YOUR_TOKEN

Enter fullscreen mode Exit fullscreen mode

The && is critical — it only pings if the backup succeeds. If the script exits non-zero, no ping is sent, and you get alerted.

Grace Periods

Not every job runs at exactly the same time. A good monitoring system lets you set a grace period — extra time before an alert fires.

For a daily backup that usually takes 10 minutes:

  • Schedule: every 1440 minutes (24 hours)
  • Grace period: 30 minutes
  • Alert fires if no ping received within 24.5 hours of the last one

Failure Modes

Failure Mode Log Monitoring Heartbeat Monitoring
Script errors out Catches Catches (no ping sent)
Script never starts Nothing to log Catches (no ping)
Server is down Can't log Catches (no ping)
Script hangs forever No error logged Catches (late ping)
Crontab deleted Nothing happens Catches (no ping)

Heartbeat monitoring catches every failure mode because it monitors for the absence of a signal rather than the presence of an error.

Setting Up CronPing

I built CronPing to make this dead-simple:

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

# 2. Create a monitor
curl -X POST https://cronping.anethoth.com/api/v1/monitors \
  -H 'Authorization: Bearer ch_xxx...' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "nightly-backup", "schedule_minutes": 1440, "grace_minutes": 30 }'

# 3. Add the ping to your cron job
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://cronping.anethoth.com/ping/xxx

Enter fullscreen mode Exit fullscreen mode

Free tier gives you 3 monitors — enough for most side projects.

Best Practices

  1. Always use && — only ping on success
  2. Use -fsS with curl — fail silently on network errors but show server errors
  3. Set realistic grace periods — too tight causes false alarms
  4. One monitor per job — don't reuse ping tokens

CronPing is free for up to 3 monitors. Try the cron expression helper to build your cron schedules.