Cleaning Up Duplicate Cron Jobs on Asterisk Servers

Administration -- Last reviewed 2026-04-01 cron administration automation Found this useful? Upvote it. ×

The Problem

Over time, especially with configuration management tools (Ansible, Puppet) or manual administration, duplicate cron jobs accumulate. Common on PBX servers where monitoring scripts get added in multiple places.

Diagnosis

# List all cron sources
ls -la /etc/cron.d/
crontab -l 2>/dev/null
sudo crontab -l 2>/dev/null

# Check for duplicate script references
grep -r 'trunk-monitor\|pbx-backup\|asterisk' /etc/cron.d/

In our case, we found:

/etc/cron.d/pbx-monitoring     -- the intended cron file (deployed by our script)
/etc/cron.d/asterisk-backup    -- duplicate backup job (stale)
/etc/cron.d/asterisk-trunk-monitor -- duplicate trunk monitor running every MINUTE

The trunk monitor running every minute was generating unnecessary load and log noise.

Fix

# Remove duplicates, keep only the canonical cron file
sudo rm /etc/cron.d/asterisk-backup
sudo rm /etc/cron.d/asterisk-trunk-monitor

# Verify only the intended cron remains
ls /etc/cron.d/pbx-monitoring
cat /etc/cron.d/pbx-monitoring

Prevention

# In deploy.sh
for stale in asterisk-backup asterisk-trunk-monitor; do
    ssh_cmd "sudo rm -f /etc/cron.d/${stale}"
done

User Notes

No notes yet. Be the first to contribute a tip or example.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.

Related Snippets