6.2 KiB
Linux System Updater: Administrator Guide
This guide covers enterprise deployment, automated scheduling, monitoring, log management, and configuration tuning for linux-updater.
1. Automated Execution (Cron & Systemd)
For automated maintenance windows, run linux-updater non-interactively using the -y (--non-interactive) flag.
A. Systemd Service & Timer (Recommended)
Create /etc/systemd/system/linux-updater.service:
[Unit]
Description=Automated Safe Linux System Updater
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/linux-updater -y update
StandardOutput=journal
StandardError=journal
Create /etc/systemd/system/linux-updater.timer:
[Unit]
Description=Weekly automated system update
[Timer]
OnCalendar=Sun *-*-* 03:00:00
Persistent=true
RandomizedDelaySec=1800
[Install]
WantedBy=timers.target
Enable and activate the timer:
sudo systemctl daemon-reload
sudo systemctl enable --now linux-updater.timer
sudo systemctl list-timers linux-updater.timer
B. Standard Cron Job
Alternatively, add an entry to /etc/cron.d/linux-updater:
# Run every Sunday at 03:30 AM
30 3 * * 0 root /usr/bin/linux-updater -y update > /dev/null 2>&1
2. Configuration Reference (/etc/linux-updater.json)
The default configuration file /etc/linux-updater.json governs health check thresholds and update behaviors:
{
"thresholds": {
"min_boot_mb": 250,
"min_var_mb": 1024,
"min_root_mb": 1024,
"min_ram_mb": 300
},
"behavior": {
"auto_remediate": true,
"non_interactive": false,
"check_ac_power": true,
"clean_after_update": false,
"auto_reboot": false,
"exclude_packages": [],
"security_only": false,
"update_flatpak": false
},
"logging": {
"log_dir": "/var/log/linux-updater",
"log_file": null,
"verbose": false
}
}
Threshold Parameters
min_boot_mb: Minimum required free space in/boot. Prevents failed kernel installations. Defaults to 250 MB.min_var_mb: Minimum required free space in/var. If space drops below this, auto-remediation triggers a cache purge. Defaults to 1024 MB (1 GB).min_root_mb: Minimum free space on root/. Defaults to 1024 MB.min_ram_mb: Available RAM threshold in/proc/meminfo. Protects against OOM killer crashing package scripts. Defaults to 300 MB.
Behavior Parameters
auto_remediate: Whentrue, automatically clears package cache if/varis low, unlinks stale locks if the holder PID is dead, and repairs interrupted package transactions (dpkg --configure -a,apt-get install -f,dnf clean all).non_interactive: Default non-interactive state. (Overridden by CLI-y).check_ac_power: Inspects/sys/class/power_supplyand warns/halts if running on battery power.clean_after_update: Iftrue, runsautoremoveautomatically after successful updates.auto_reboot: Whentrue, automatically triggers reboot if a kernel or core system component was upgraded.exclude_packages: List of package names or glob patterns to skip during update transactions.security_only: Whentrue, restricts all update operations strictly to security patches.update_flatpak: Whentrue, executesflatpak update -yafter OS packages update if flatpak is installed.
3. Monitoring & Structured JSON Integration
linux-updater includes native --json output for direct consumption by monitoring agents (Zabbix, Wazuh, Prometheus node exporter textfile collector).
Health Monitoring Check
linux-updater health --json
JSON Output:
{
"passed": true,
"results": [
{
"name": "disk_boot",
"status": "PASS",
"message": "/boot free space is sufficient: 1042MB",
"can_remediate": false,
"remediation_id": null
},
{
"name": "disk_var",
"status": "PASS",
"message": "/var free space is sufficient: 42100MB",
"can_remediate": false,
"remediation_id": null
},
{
"name": "memory_available",
"status": "PASS",
"message": "Available RAM is sufficient: 7850MB",
"can_remediate": false,
"remediation_id": null
},
{
"name": "pending_reboot",
"status": "PASS",
"message": "No pending system reboot detected.",
"can_remediate": false,
"remediation_id": null
},
{
"name": "package_db",
"status": "PASS",
"message": "Package database is consistent.",
"can_remediate": false,
"remediation_id": null
}
],
"remediations_performed": []
}
Exit Code Handling in Automation Scripts
In shell scripts, handle the four deterministic exit codes:
#!/bin/bash
linux-updater -y update
STATUS=$?
case $STATUS in
0)
echo "Updates succeeded cleanly. No reboot required."
;;
1)
echo "Update or health check failed! Raising alert." >&2
exit 1
;;
2)
echo "Updates applied successfully. System reboot required!"
# Optional automated reboot:
# /sbin/reboot
;;
3)
echo "Operation aborted by user."
;;
esac
4. Log Management & Logrotate
By default, logs are written to /var/log/linux-updater/ conforming to Linux FHS:
- Timestamped files:
linux-updater-YYYYMMDD-HHMMSS.log - Symlink to latest run:
/var/log/linux-updater/latest.log
The package installation automatically provides /etc/logrotate.d/linux-updater:
/var/log/linux-updater/*.log {
weekly
rotate 4
compress
missingok
notifempty
create 0640 root root
}
5. Shell Tab Autocompletion Deployment
For administrative workstations and fleet servers, shell completions can be automatically deployed:
- System-wide Bash:
/usr/share/bash-completion/completions/linux-updater - System-wide Zsh:
/usr/share/zsh/site-functions/_linux-updater(or/usr/share/zsh/vendor-completions/_linux-updater)
Both files are automatically placed when installing via .deb, .rpm, or install.sh. Administrators can also dynamically output and evaluate them:
# Bash:
linux-updater completion bash > /etc/bash_completion.d/linux-updater
# Zsh:
linux-updater completion zsh > /usr/local/share/zsh/site-functions/_linux-updater