Watchdog
The watchdog ensures your blocking rules are enforced automatically, even if something tries to disable it.
What is the Watchdog?
Section titled “What is the Watchdog?”The watchdog is a background process that:
- Runs
config pushevery 2 minutes - Enforces your schedules - Self-heals - Restores itself if deleted
- Uses native schedulers - launchd, cron, Task Scheduler
- Logs activity - Track what’s happening
How It Works
Section titled “How It Works”┌─────────────────────────────────────────────────────────────┐│ Platform Scheduler ││ (launchd / cron / Task Scheduler) │└─────────────────────────────────────────────────────────────┘ │ │ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ │ Sync Job │ │ Watchdog Job │ │ (every 2 min) │ │ (every 5 min) │ └─────────────────┘ └─────────────────┘ │ │ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ │ nextdns-blocker │ │ Check if sync │ │ config push │ │ job exists │ └─────────────────┘ └─────────────────┘ │ ▼ ┌─────────────────┐ │ Restore sync │ │ job if missing │ └─────────────────┘Two Jobs
Section titled “Two Jobs”- Sync Job: Runs
nextdns-blocker config pushevery 2 minutes - Watchdog Job: Checks sync job exists every 5 minutes, restores if missing
Installing Watchdog
Section titled “Installing Watchdog”nextdns-blocker watchdog installOutput:
Installing watchdog jobs...
Platform: macOS (launchd)
Creating jobs: ✓ NextDNS-Blocker-Sync (every 2 minutes) ✓ NextDNS-Blocker-Watchdog (every 5 minutes)
Jobs installed successfullyChecking Status
Section titled “Checking Status”nextdns-blocker watchdog statusOutput:
Watchdog Status━━━━━━━━━━━━━━━
Platform: macOS (launchd)Status: Active ✓
Jobs: NextDNS-Blocker-Sync Schedule: Every 2 minutes Last run: 2024-01-15 14:28:00 Next run: 2024-01-15 14:30:00
NextDNS-Blocker-Watchdog Schedule: Every 5 minutes Purpose: Ensures sync job existsPlatform-Specific Details
Section titled “Platform-Specific Details”macOS (launchd)
Section titled “macOS (launchd)”Jobs created as plist files:
Location: ~/Library/LaunchAgents/
Files:
com.nextdns-blocker.sync.plistcom.nextdns-blocker.watchdog.plist
Commands:
# View jobsls ~/Library/LaunchAgents/com.nextdns-blocker.*
# Check statuslaunchctl list | grep nextdns
# Manual load/unloadlaunchctl load ~/Library/LaunchAgents/com.nextdns-blocker.sync.plistlaunchctl unload ~/Library/LaunchAgents/com.nextdns-blocker.sync.plistLinux (cron)
Section titled “Linux (cron)”Jobs added to user crontab:
View:
crontab -lExpected entries:
*/2 * * * * /path/to/nextdns-blocker config push >> ~/.local/share/nextdns-blocker/logs/cron.log 2>&1*/5 * * * * /path/to/nextdns-blocker watchdog check >> ~/.local/share/nextdns-blocker/logs/wd.log 2>&1Check cron service:
systemctl status cron# orsystemctl status crondWindows (Task Scheduler)
Section titled “Windows (Task Scheduler)”Tasks created in Task Scheduler:
View:
# Command lineschtasks /query /tn "NextDNS-Blocker-Sync"schtasks /query /tn "NextDNS-Blocker-Watchdog"
# GUItaskschd.mscManual run:
schtasks /run /tn "NextDNS-Blocker-Sync"Disabling Temporarily
Section titled “Disabling Temporarily”Need to pause automatic syncing:
# Disable for 1 hournextdns-blocker watchdog disable 1
# Disable for 4 hoursnextdns-blocker watchdog disable 4
# Disable permanently (until re-enabled)nextdns-blocker watchdog disableRe-enabling
Section titled “Re-enabling”nextdns-blocker watchdog enableUninstalling
Section titled “Uninstalling”Remove all watchdog jobs:
nextdns-blocker watchdog uninstallUse before:
- Uninstalling NextDNS Blocker
- Switching to Docker deployment
- Debugging issues
Log Files
Section titled “Log Files”Sync Log
Section titled “Sync Log”Output from sync executions:
tail -f ~/.local/share/nextdns-blocker/logs/cron.logWatchdog Log
Section titled “Watchdog Log”Watchdog events (job restoration):
tail -f ~/.local/share/nextdns-blocker/logs/wd.logLog Locations
Section titled “Log Locations”| Platform | Path |
|---|---|
| macOS/Linux | ~/.local/share/nextdns-blocker/logs/ |
| Windows | %LOCALAPPDATA%\nextdns-blocker\logs\ |
Self-Healing
Section titled “Self-Healing”How It Works
Section titled “How It Works”- Watchdog job runs every 5 minutes
- Checks if sync job exists
- If missing, recreates it
- Logs recovery event
Why Self-Healing?
Section titled “Why Self-Healing?”Prevents circumvention:
- Manual deletion of cron jobs
- Accidental removal
- System cleanup tools
- Other users on shared systems
Recovery Log
Section titled “Recovery Log”2024-01-15 14:35:00 - Sync job missing, restoring...2024-01-15 14:35:01 - Sync job restored successfullyTroubleshooting
Section titled “Troubleshooting”Watchdog not running
Section titled “Watchdog not running”-
Check status:
Terminal window nextdns-blocker watchdog status -
Reinstall:
Terminal window nextdns-blocker watchdog uninstallnextdns-blocker watchdog install -
Check scheduler service:
Terminal window # Linuxsystemctl status cron# macOSlaunchctl list | grep nextdns
Sync not executing
Section titled “Sync not executing”-
Check logs:
Terminal window tail -20 ~/.local/share/nextdns-blocker/logs/cron.log -
Test manually:
Terminal window nextdns-blocker config push --verbose -
Check executable path:
Terminal window which nextdns-blocker
Permission issues
Section titled “Permission issues”macOS:
- Grant Full Disk Access to Terminal (System Preferences → Security)
Linux:
- Check crontab ownership
- Verify executable permissions
Windows:
- Run PowerShell as Administrator for initial setup
- Check Task Scheduler permissions
Jobs keep disappearing
Section titled “Jobs keep disappearing”Both jobs disappearing indicates system-level issue:
- Check antivirus/security software
- Verify user has scheduler access
- Check for system cleanup tools
- Review system logs for errors
Best Practices
Section titled “Best Practices”- Always install watchdog - Manual sync is unreliable
- Check status weekly - Verify it’s running
- Monitor logs - Catch issues early
- Don’t disable long-term - Re-enable after debugging
- Test after system updates - May need reinstall