Cron Scheduling - Automate Update Checks
Update-Watcher is designed to run on a schedule, checking for available updates and sending notifications automatically. This page covers all scheduling options, from the built-in install-cron command to manual crontab configuration and output logging.
Setting Up a Schedule
Using install-cron
The simplest way to set up a daily schedule is the built-in install-cron command:
update-watcher install-cron --time 07:00This creates a cron entry that runs update-watcher run --quiet every day at 07:00. The --quiet flag suppresses terminal output, which is appropriate for unattended cron execution.
To use the default time of 07:00, the --time flag can be omitted:
update-watcher install-cronFor a custom cron expression (e.g., twice daily):
update-watcher install-cron --cron-expr "0 7,19 * * *"See install-cron for full command documentation.
Manual Crontab Setup
For more control, edit the crontab directly.
Current User
crontab -eDedicated Service User
On Linux servers with a dedicated update-watcher user:
sudo crontab -u update-watcher -eDedicated Service User Entry
When running as a dedicated system user on Linux, include the --as-service-user flag:
0 7 * * * /usr/local/bin/update-watcher run --quiet --as-service-userSchedule Examples
/usr/local/bin/update-watcher). This is important because cron runs with a minimal PATH.Daily at 07:00 (the most common setup):
0 7 * * * /usr/local/bin/update-watcher run --quietTwice daily at 07:00 and 19:00:
0 7,19 * * * /usr/local/bin/update-watcher run --quietEvery Monday at 06:00 (weekly):
0 6 * * 1 /usr/local/bin/update-watcher run --quietEvery 6 hours:
0 */6 * * * /usr/local/bin/update-watcher run --quietWeekdays only at 08:00:
0 8 * * 1-5 /usr/local/bin/update-watcher run --quietLogging Cron Output
Cron jobs run silently by default. To capture output for debugging and auditing, you have several options.
Redirect to a Log File
Append stdout and stderr to a log file directly in the crontab entry:
0 7 * * * /usr/local/bin/update-watcher run --quiet 2>&1 >> /var/log/update-watcher-cron.logUse the Built-in Log File
Configure a log file in your config.yaml:
settings:
log_file: "/var/log/update-watcher.log"With this setting, Update-Watcher writes structured log output to the specified file on every run, regardless of cron redirection.
Cron Mail
By default, cron emails any output to the crontab owner. If your server has a local mail transport agent (MTA) configured, you can rely on this for notifications about cron failures. However, the --quiet flag suppresses most output. Remove --quiet if you want cron mail to include the full report:
0 7 * * * /usr/local/bin/update-watcher run 2>&1Verifying Cron Is Running
Check the Crontab
View the active cron entries:
crontab -lFor the dedicated service user:
sudo crontab -u update-watcher -lCheck Cron Logs
On systems with syslog, cron execution is logged:
grep update-watcher /var/log/syslogOn systemd-based systems:
journalctl -u cron --grep update-watcherCheck the Application Log
If a log file is configured, check the last entry:
tail -20 /var/log/update-watcher.logVerify Manually
Run the exact command that cron executes to verify it works:
# As your user
/usr/local/bin/update-watcher run --quiet
# As the dedicated service user
sudo -u update-watcher /usr/local/bin/update-watcher run --quiet --as-service-userAutomated Self-Updates
In addition to scheduling update checks, you can schedule automatic self-updates of the Update-Watcher binary. This ensures your monitoring tool stays current with the latest features and fixes.
update-watcher install-cron --type self-update --cron-expr "0 3 * * 0"This runs update-watcher self-update every Sunday at 3:00 AM. Both job types are managed independently – you can install, update, or remove them separately.
A typical production setup with both jobs:
# update-watcher scheduled check
0 7 * * * /usr/local/bin/update-watcher run --quiet 2>&1 | logger -t update-watcher
# update-watcher self-update
0 3 * * 0 /usr/local/bin/update-watcher self-update 2>&1 | logger -t update-watcherSee install-cron for all --type options and flags.
Removing Cron Jobs
Using uninstall-cron
Remove the check job:
update-watcher uninstall-cronRemove the self-update job:
update-watcher uninstall-cron --type self-updateRemove all Update-Watcher cron jobs:
update-watcher uninstall-cron --allFor the dedicated service user:
sudo -u update-watcher update-watcher uninstall-cron --allManually
Edit the crontab and remove the Update-Watcher lines:
crontab -eOr for the service user:
sudo crontab -u update-watcher -eTroubleshooting
Troubleshooting: Cron Job Not Running
Common causes:
/usr/local/bin/update-watcher) in crontab entries.- Permission denied – The user’s crontab may not have permission to execute the binary or read the config file.
- Cron daemon not running – Check with
systemctl status cronorsystemctl status crond.
Troubleshooting: Notifications Not Arriving
Run the command manually with --verbose to diagnose:
sudo -u update-watcher update-watcher run --verboseCheck that the send_policy is not set to only-on-updates when there are no updates to report. Use --notify=true to force a notification for testing:
sudo -u update-watcher update-watcher run --notify=trueRelated
- install-cron – Built-in cron job management.
- uninstall-cron – Remove the cron job.
- Linux Server Setup – Full server setup guide.
- macOS Setup – macOS scheduling with cron and launchd.