DST Pitfalls
Avoid common Daylight Saving Time issues in cron scheduling.
Warning: DST transitions can cause cron jobs to run twice, skip execution, or run at unexpected times.
Spring Forward (2 AM → 3 AM)
⚠️ Time Jump Problem
Jobs scheduled between 2:00-2:59 AM will be skipped!
# This job will be skipped during spring DST
0 2 * * * /path/to/important-backup.sh
Fall Back (2 AM → 1 AM)
⚠️ Double Execution
Jobs scheduled between 1:00-1:59 AM will run twice!
# This job will run TWICE during fall DST
0 1 * * * /path/to/billing-process.sh
Solutions
✅ Use UTC
# Set timezone to UTC in crontab
TZ=UTC
0 8 * * * /path/to/script.sh # Always 8 AM UTC
✅ Avoid Problematic Hours
# Schedule at 3 AM instead of 2 AM
0 3 * * * /path/to/backup.sh
# Or use noon (no DST issues)
0 12 * * * /path/to/daily-task.sh
✅ Idempotent Scripts
Make scripts safe to run multiple times:
#!/bin/bash
# Check if already running today
LOCKFILE="/tmp/daily-backup.lock"
if [ -f "$LOCKFILE" ]; then
echo "Already ran today, skipping"
exit 0
fi
# Run backup and create lock
/path/to/backup.sh && touch "$LOCKFILE"
Testing DST
DST Test Dates (2024)
Spring Forward: March 10, 2024 (2 AM → 3 AM)
Fall Back: November 3, 2024 (2 AM → 1 AM)