PVE Cron LXC Updater
Install, update or remove a weekly cron job that updates the operating system of all LXC containers.
cron-update-lxcs.sh is a manager. It downloads the worker script update-lxcs-cron.sh, lets you read it, installs it as a local file and adds a root cron entry that runs that local file. Cron never downloads code at run time.
Website entry: cron-update-lxcs. Source: tools/pve/cron-update-lxcs.sh.
Run
In the Proxmox VE host shell, as root:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/cron-update-lxcs.sh)"Menu
The script opens the menu "Cron Update LXCs". Cancel exits.
| Entry | What it does |
|---|---|
Add | Downloads the worker, prints an installation summary with the SHA256 of the download, asks "Review script content before installing?" (prints the file) and "Install this script and activate cron schedule?". On yes it installs the worker with mode 0755, creates the config file if it is missing and adds the cron entry. |
Remove | Removes the cron entry, the worker and the log file. No confirmation. The config file is kept. |
Update | Downloads the current worker and shows a diff against the installed one with both SHA256 sums. "Apply update?" replaces the installed file. Without changes it reports "already up-to-date". |
Status | Shows whether the worker is installed (SHA256, install time), the cron schedule, excluded IDs, ping URL, log size and the last run. |
Run | Runs the installed worker now and appends its output to the log. |
View | Sub-menu: Worker (prints the installed script), Cron (cron entry, config file, log size) or Both. |
Rotate | Asks "Rotate log file?" and moves the log to /var/log/update-lxcs-cron.log.old. |
Update, Run and View stop with an error if the worker is not installed yet.
Files and cron entry
| Path | Purpose |
|---|---|
/usr/local/bin/update-lxcs.sh | The installed worker. |
/etc/update-lxcs.conf | Settings, created by Add if missing. |
/var/log/update-lxcs-cron.log | Output of every run. |
| root crontab | 0 0 * * 0 /usr/local/bin/update-lxcs.sh >>/var/log/update-lxcs-cron.log 2>&1 (every Sunday at midnight) |
Add and Remove also delete an older cron line that contains update-lxcs-cron.sh, the entry earlier versions installed.
Configuration
/etc/update-lxcs.conf as created by Add:
# Configuration for automatic LXC container OS updates.
# Add container IDs to exclude from updates (comma-separated):
# EXCLUDE=100,101,102
EXCLUDE=
# Healthchecks.io Ping URL (optional)
# PING_URL=| Key | Effect |
|---|---|
EXCLUDE | Comma-separated container IDs the worker skips. |
PING_URL | The worker requests <PING_URL>/start before the run and sends the log to <PING_URL> on success or <PING_URL>/fail on failure. With a ping URL set, the log file is emptied at the start of every run. |
To change the schedule, edit the line with crontab -e. View describes 0 0 * * 0, 0 0 * * * and 0 * * * * in words and calls anything else "Custom schedule"; Status prints the five schedule fields as they are.
Undo
Choose Remove, then delete /etc/update-lxcs.conf by hand if you do not want to keep it.
Limits
- The manager reads no environment variables.
Adddoes not ask for a schedule; it always writes the Sunday entry and replaces an existing entry for the same file.