Reference · Linux servers
Silent failures on an Ubuntu server: failed units, unattended upgrades, certbot and pending restarts
Find the failures an Ubuntu server does not announce: systemctl --failed, the unattended-upgrades log and a dry run, certbot.timer and certbot renew --dry-run, /var/run/reboot-required and reboot-required.pkgs, and needrestart.
| Target artifact | The background jobs of an Ubuntu server: systemd units, the daily security update run, certbot's renewal timer, restarts that updates are waiting for, and services still running replaced libraries. |
|---|---|
| Default behaviour | Ubuntu Server installs security updates daily through apt-daily-upgrade.timer, and on 24.04 needrestart restarts affected services itself. Nothing reboots the server: Unattended-Upgrade::Automatic-Reboot is false, and a pending restart shows only as a file and a line in the login message. No report is emailed unless Unattended-Upgrade::Mail is set. |
| Safe state | systemctl --failed lists 0 units; the unattended-upgrades log shows a run within the last day and no ERROR lines; certbot renew --dry-run succeeds; /var/run/reboot-required is absent, or a reboot is planned; needrestart -r l lists no services. |
| Check on Linux | systemctl --failed |
| Check on Linux | sudo tail -n 20 /var/log/unattended-upgrades/unattended-upgrades.log |
| Check on Linux | sudo certbot renew --dry-run |
| Check on Linux | cat /var/run/reboot-required /var/run/reboot-required.pkgs |
| Fix on Linux | fix the cause, then sudo systemctl reset-failed UNIT_NAME; reboot in a planned window while /var/run/reboot-required exists |
Failed units
systemctl --failed
systemctl is-system-running
journalctl -u UNIT_NAME -b --no-pager -n 50--failedlists units in the failed state.is-system-runningprintsdegradedwhen one or more units have failed, and exits with a non-zero code, which suits monitoring scripts.- systemd's manual says a unit whose process exits with a non-zero code, ends abnormally or times out enters the failed state, and stays there until it is restarted or reset.
- After fixing the cause, clear the state with
sudo systemctl reset-failed UNIT_NAME. Guide 5 explains why: a list that is never empty hides the next failure.
Timers start services too: certbot.timer starts certbot.service, and certbot renew exits with 1 when a renewal fails, so a failed renewal leaves certbot.service in this list.
Unattended upgrades
unattended-upgrades.service is not the daily job. On 24.04 its unit is described as "Unattended Upgrades Shutdown" and only handles shutdown. The daily run comes from apt-daily-upgrade.timer, which starts apt-daily-upgrade.service; the unattended-upgrade manual says it is designed to run from that service.
systemctl list-timers apt-daily.timer apt-daily-upgrade.timer
cat /etc/apt/apt.conf.d/20auto-upgrades
sudo tail -n 20 /var/log/unattended-upgrades/unattended-upgrades.loglist-timersshows when each timer last ran and runs next. On 24.04,apt-daily.timerdownloads package lists at 06:00 and 18:00 with up to 12 hours of random delay, andapt-daily-upgrade.timerinstalls updates at 06:00 with up to 60 minutes of delay. A run missed while the server was off may happen at the next start.- In
20auto-upgrades, each value is a number of days:"1"runs daily,"0"turns the action off. - The log records every run. The line with
Packages that will be upgraded:names what each run upgrades; look forWARNINGandERRORlines. The folder is readable only by root and theadmgroup.
Test a run
sudo unattended-upgrade --dry-run --debug--dry-run simulates the run without installing anything, and --debug adds detail, which also goes into the log. The output lists the allowed origins, the archives it takes updates from (on 24.04, noble, noble-security and the Expanded Security Maintenance archives), then the packages it would upgrade. A dry run still ends with All upgrades installed, although nothing was installed.
To get a report after each real run, set Unattended-Upgrade::Mail in /etc/apt/apt.conf.d/50unattended-upgrades; Ubuntu's documentation notes that the server then needs a mail package to send it.
Certificate renewals
systemctl list-timers certbot.timer
sudo certbot renew --dry-run
sudo certbot certificates- Ubuntu's
certbotpackage installscertbot.timer, which runscertbot -q renewtwice a day at random times. Certbot installed another way has its own timer or cron job; Certbot's documentation says to look insystemctl list-timersor the crontab. certbot renewonly renews certificates close to expiry. From Certbot 4.0.0, that means less than a third of the lifetime left, or less than half for certificates that last 10 days or less; earlier versions, including the 2.9.0 package in Ubuntu 24.04, used a fixed 30 days.--dry-runtests whether future renewals will succeed. With no certificates it reportsNo simulated renewals were attempted.certbot certificatesshows each certificate'sExpiry Datewith the days left, as(VALID: 30 days). If the days left stay below the renewal threshold, renewals are failing.certbot renewexits with 1 only if a renewal attempt failed. Its logs are in/var/log/letsencrypt.
Pending restarts
cat /var/run/reboot-required /var/run/reboot-required.pkgs 2>/dev/null- A package that needs a reboot, such as a new kernel, runs update-notifier's
notify-reboot-required. It writes*** System restart required ***to/var/run/reboot-requiredand adds the package name to/var/run/reboot-required.pkgs. Ubuntu's login message prints the first file. /var/runpoints to/run, which is cleared at every boot, so both files disappear after the restart.- With Canonical Livepatch, the client can remove the reboot notice after a kernel update, when it proves that Livepatch already covers the flaws the new kernel fixes; Livepatch's own message then shows Protected or Reboot required. The notice stays when other packages need the restart, when the check fails, or with the
livepatch-agnosticpolicy. Canonical notes that once the notice is removed, unattended-upgrades' automatic reboot does not restart the machine and monitoring tools no longer report it. - Unattended upgrades reboot on their own, without confirmation, only when
Unattended-Upgrade::Automatic-Rebootis"true"and/var/run/reboot-requiredexists after the upgrade: at once, or at the time set inUnattended-Upgrade::Automatic-Reboot-Time.
Services on replaced libraries
sudo needrestart -r l- From Ubuntu 24.04,
needrestartruns after updates and restarts affected services automatically, Ubuntu's documentation says.-r lonly lists what still needs a restart; it also checks the kernel and the processor microcode. - To keep a service from being restarted, Ubuntu's documentation says to add a file in
/etc/needrestart/conf.d/instead of editingneedrestart.conf, and to set that service's$nrconf{override_rc}entry to0. To have needrestart only list, and restart services yourself:
$nrconf{restart} = 'l';What runs when
| Job | When it runs on 24.04 | Where to look |
|---|---|---|
Security updates, apt-daily-upgrade.timer | Daily at 06:00, up to 60 minutes late | /var/log/unattended-upgrades/ |
Package lists, apt-daily.timer | 06:00 and 18:00, up to 12 hours late | systemctl list-timers |
Certificate renewal, certbot.timer | Twice a day at random times | systemctl --failed, certbot certificates |
Service restarts, needrestart | After each package installation | needrestart -r l |
| Reboot required | When a package asks for one | /var/run/reboot-required and the login message |
The times in this table come from the packages' timer units; Ubuntu's documentation gives no interval for checking them. Updates and renewals run every day, and a failure stays silent until someone runs the checks on this page or reads an emailed report.
Related guides and lookups
Sources
- systemd manual: systemctl, --failed, reset-failed, list-timers and is-system-running
- systemd manual: journalctl
- Ubuntu Server documentation: automatic updates
- Ubuntu manual: unattended-upgrade, 24.04
- Certbot: user guide, renewing certificates
- Certbot: instructions for Apache on Linux (snap), test automatic renewal
- Ubuntu Discourse: package maintainer scripts and the reboot-required hooks
- Launchpad bug 1747499: 98-reboot-required and Livepatch
- Canonical Livepatch: how reboot notices are removed after a kernel update
- Filesystem Hierarchy Standard: /run