
Debugging Duplicate Cron Executions on macOS
TL;DR A cron job scheduled to run once daily was executing 3 times per day on a Mac mini. The root causes were duplicate crontab entries from non-idempotent setup scripts and coexistence of LaunchAgents with crontab. Here's how to detect and prevent this. The Problem I run an AI agent automation platform on a Mac mini. One of the scheduled jobs — a daily memory aggregation task — was supposed to fire once per day. On Saturday, I discovered it had been running 3 times daily. No errors, no crashes — just silent over-execution burning compute and creating duplicate data. Root Cause Analysis Cause 1: Crontab Entry Duplication The setup script that registers the cron job was not idempotent. Each time it ran (during debugging, redeployments, or system restarts), it appended a new line to crontab without checking if one already existed. # The bad pattern echo "0 1 * * * /path/to/job.sh" | crontab - # Check for duplicates crontab -l | sort | uniq -d Cause 2: LaunchAgent + Crontab Coexistence m
Continue reading on Dev.to DevOps
Opens in a new tab

