watchdog
The watchdog command group manages automatic synchronization using your platform’s native scheduler.
Overview
Section titled “Overview”The watchdog:
- Runs
config pushevery 2 minutes - Uses platform-native schedulers (launchd, cron, Task Scheduler)
- Restores itself if removed
- Can be temporarily disabled
Subcommands
Section titled “Subcommands”| Subcommand | Description |
|---|---|
status | Check scheduler status |
install | Create scheduled sync jobs |
uninstall | Remove scheduled jobs |
enable | Re-enable after disable |
disable | Temporarily disable |
watchdog status
Section titled “watchdog status”Check if the watchdog is running and view its status.
nextdns-blocker watchdog statusOutput
Section titled “Output”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 existsStatus Values
Section titled “Status Values”| Status | Meaning |
|---|---|
| Active | Jobs are scheduled and running |
| Inactive | Jobs not installed |
| Disabled | Temporarily disabled by user |
| Error | Jobs exist but have issues |
watchdog install
Section titled “watchdog install”Create the scheduled synchronization jobs.
nextdns-blocker watchdog installOutput
Section titled “Output”Installing watchdog jobs...
Platform: macOS (launchd)
Creating jobs: ✓ NextDNS-Blocker-Sync (every 2 minutes) ✓ NextDNS-Blocker-Watchdog (every 5 minutes)
Jobs installed successfullyLocation: ~/Library/LaunchAgents/
Run 'watchdog status' to verifyPlatform-Specific Behavior
Section titled “Platform-Specific Behavior”| Platform | Scheduler | Location |
|---|---|---|
| macOS | launchd | ~/Library/LaunchAgents/ |
| Linux | cron | crontab -l |
| Windows | Task Scheduler | View in taskschd.msc |
watchdog uninstall
Section titled “watchdog uninstall”Remove the scheduled jobs.
nextdns-blocker watchdog uninstallOutput
Section titled “Output”Removing watchdog jobs...
✓ NextDNS-Blocker-Sync removed ✓ NextDNS-Blocker-Watchdog removed
Watchdog uninstalledAutomatic syncing is now disabledWhen to Uninstall
Section titled “When to Uninstall”- Before uninstalling NextDNS Blocker
- When switching to Docker or another deployment
- For debugging issues
watchdog enable
Section titled “watchdog enable”Re-enable the watchdog after it was disabled.
nextdns-blocker watchdog enableOutput
Section titled “Output”Watchdog enabled ✓Automatic syncing will resume immediatelywatchdog disable
Section titled “watchdog disable”Temporarily disable the watchdog.
nextdns-blocker watchdog disable [HOURS]Arguments
Section titled “Arguments”| Argument | Default | Description |
|---|---|---|
HOURS | Permanent | Hours to disable (1-24) |
Examples
Section titled “Examples”# Disable for 1 hournextdns-blocker watchdog disable 1
# Disable for 4 hoursnextdns-blocker watchdog disable 4
# Disable permanently (until manually enabled)nextdns-blocker watchdog disableOutput
Section titled “Output”Watchdog disabled for 4 hoursRe-enables at: 2024-01-15 18:30:00
Use 'watchdog enable' to re-enable earlyUse Cases
Section titled “Use Cases”- Debugging sync issues
- Testing configuration changes manually
- Temporarily managing blocking manually
How Watchdog Works
Section titled “How Watchdog Works”Sync Job
Section titled “Sync Job”Runs every 2 minutes:
- Executes
nextdns-blocker config push - Logs output to
cron.log - Handles errors gracefully
Watchdog Job
Section titled “Watchdog Job”Runs every 5 minutes:
- Checks if sync job exists
- Recreates sync job if missing
- Logs recovery events to
wd.log
This self-healing mechanism ensures blocking continues even if the sync job is accidentally deleted.
Log Files
Section titled “Log Files”| Log | Purpose | Location |
|---|---|---|
cron.log | Sync execution output | ~/.local/share/nextdns-blocker/logs/ |
wd.log | Watchdog events | ~/.local/share/nextdns-blocker/logs/ |
Viewing Logs
Section titled “Viewing Logs”# Sync logstail -f ~/.local/share/nextdns-blocker/logs/cron.log
# Watchdog logstail -f ~/.local/share/nextdns-blocker/logs/wd.logPlatform-Specific Details
Section titled “Platform-Specific Details”macOS (launchd)
Section titled “macOS (launchd)”Jobs are created as property list files:
# View installed jobsls ~/Library/LaunchAgents/com.nextdns-blocker.*
# View job detailsplutil -p ~/Library/LaunchAgents/com.nextdns-blocker.sync.plist
# Manually load/unloadlaunchctl load ~/Library/LaunchAgents/com.nextdns-blocker.sync.plistlaunchctl unload ~/Library/LaunchAgents/com.nextdns-blocker.sync.plistLinux (cron)
Section titled “Linux (cron)”Jobs are added to your user’s crontab:
# View cron jobscrontab -l
# Expected 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>&1Windows (Task Scheduler)
Section titled “Windows (Task Scheduler)”Tasks are created in Task Scheduler:
# List tasksschtasks /query /tn "NextDNS-Blocker-Sync"schtasks /query /tn "NextDNS-Blocker-Watchdog"
# Open Task Scheduler GUItaskschd.msc
# Manually runschtasks /run /tn "NextDNS-Blocker-Sync"Troubleshooting
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
Sync not executing
Section titled “Sync not executing”-
Check logs:
Terminal window tail -20 ~/.local/share/nextdns-blocker/logs/cron.log -
Test sync manually:
Terminal window nextdns-blocker config push --verbose -
Check scheduler service:
Terminal window # Linuxsystemctl status cron# macOSlaunchctl list | grep nextdns
Jobs keep disappearing
Section titled “Jobs keep disappearing”This might indicate permission issues. Check:
- Crontab permissions (Linux)
- LaunchAgents folder permissions (macOS)
- Task Scheduler service is running (Windows)
The watchdog job should automatically restore the sync job, but if both are disappearing, there’s a system issue.