Cleaning Up Duplicate Cron Jobs on Asterisk Servers

Administration -- Last reviewed 2026-08-22 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 PBXPrivate Branch Exchange, a private telephone switch. Asterisk is a software PBX that routes calls between internal extensions and the outside world. 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 trunkA connection between Asterisk and another PBX or an ITSP/carrier, used to send and receive external calls. 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

Know a tip or gotcha for this topic? Share it below and help others.

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