Automatic Updates

Dexter23

Member
Dec 23, 2021
195
15
23
34
Hi everyone since i have a few server proxmox to manage, ill'ask yours if i can run a cronjob to do automatic updates on the server?
 
Code:
crontab -e

add

0 0 */10 * * /usr/bin/apt-get update && /usr/bin/apt-get -y dist-upgrade

Cron schedule (0 0 */10 * *)​

  • 0 0 */10 * *: This means the task is scheduled to run at midnight (00:00) every 10th dayof the month. Here's the breakdown:
    • 0: Minute (0th minute, meaning at the start of the hour)
    • 0: Hour (0th hour, meaning midnight)
    • */10: Every 10th day of the month (i.e., day 10, 20, 30, etc.)
    • *: Any month
    • *: Any day of the week

Command: /usr/bin/apt-get update && /usr/bin/apt-get -y dist-upgrade​

  • /usr/bin/apt-get update: This updates the list of available packages and versions from the repositories configured on the system.
  • &&: This ensures that the next command (apt-get dist-upgrade) runs only if the apt-get update command is successful.
  • /usr/bin/apt-get -y dist-upgrade: This upgrades all installed packages to the newest available versions. The -y flag automatically answers "yes" to prompts, so it can run unattended. The dist-upgrade command intelligently handles package dependencies and may install or remove packages as needed to complete the upgrade.

NEVER use apt-get upgrade this will break your Proxmox VE Host!

A quick article to that: https://www.thomas-krenn.com/de/wiki/Updates_(Minor)_in_Proxmox_VE_installieren
 
Last edited:
  • Like
Reactions: green72
i recommend and years using unattended-upgrades, and setup different times for different hosts
 
Has anyone ever done it with
Code:
Unattended-Upgrade::InstallOnShutdown "true";
before?

I tested it on a few servers. And the result is the same on all of them. The update begins during the shutdown and is then interrupted each time.
The next time you boot up the server, you first have to repair apt.
I realize that automatic updates are not intended during shutdown. But maybe someone knows what could be causing this behavior...

Unfortunately, the journal only says this:
Code:
Mar 24 21:04:45 pve-biosboot systemd[1]: Stopped getty@tty1.service - Getty on tty1.
Mar 24 21:04:45 pve-test systemd[1]: getty@tty1.service: Deactivated successfully.
Mar 24 21:04:45 pve-test stemd[1]: unattended-upgrades.service: Consumed 30.332s CPU time.

Mar 24 21:04:45 pve-test systemd[1]: Stopped unattended-upgrades.service - Unattended Upgrades Shutdown.
Mar 24 21:04:45 pve-test systemd[1]: unattended-upgrades.service: Unit process 1197 (unattended-upgr) remains running after unit stopped.
Mar 24 21:04:45 pve-test systemd[1]: unattended-upgrades.service: Unit process 1051 (unattended-upgr) remains running after unit stopped.
Mar 24 21:04:45 pve-test systemd[1]: unattended-upgrades.service: Failed with result 'exit-code'.
Mar 24 21:04:45 pve-test systemd[1]: unattended-upgrades.service: Main process exited, code=exited, status=1/FAILURE

Mar 24 21:04:45 pve-test systemd[1]: Stopped lxc-monitord.service - LXC Container Monitoring Daemon.
Mar 24 21:04:45 pve-test systemd[1]: lxc-monitord.service: Deactivated successfully.
Mar 24 21:04:45 pve-test systemd[1]: Stopped zfs-zed.service - ZFS Event Daemon (zed).
 
@fireon: systemd kills anything with a (default) timeout of 90s - you can ignore that by setting timeout of unattended-upgrades.service
to infinity - however then you run the risk of the system never actually finishing to reboot and you have to power cycle it.
 
  • Like
Reactions: fireon