Should I restart after a pacman upgrade?
The best way is to find what programs/services use the old libraries and restart them. And you can achieve it by listing all used files using 'lsof' and find those that have 'DEL' type. DEL means filename was removed from the filesystem but it is still stuck in memory because someone uses it.
Here is the full command line:
sudo lsof +c 0 | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u
If there are updates to the kernel, glibc or systemd, you may want to restart so the updated versions are in use. If you have, say, updates to your desktop environment, a simple logout/login is enough.
The only mandatory reason to reboot is a new kernel (and you can soft-reboot using kexec). See https://wiki.archlinux.org/index.php/Kexec for details, in short:
load the new kernel, initramfs and specify the boot cmdline
kexec -l /boot/new-kernel --initrd=/boot/new-initramfs --reuse-cmdline
invoke
kexec
(usesystemctl
for proper shutdown,kexec -e
would execute directly)systemctl kexec
Note that if you create a
[email protected]
as explained in the wiki, if you reboot,systemd
will automatically soft-reboot usingkexec
instead of doing a bios reboot
Little bit improved version that gives systemd service names:
PIDS="(lsof +c0 -n 2> /dev/null | grep 'DEL.*lib' | awk '{print $2}' | sort -u)"
for PID in $PIDS; do
systemctl status $i
done | grep '●' | awk '{print $2}' | sort -u
or one-line:
for i in $(lsof +c0 -n 2> /dev/null | grep 'DEL.*lib' | awk '{print $2}' | sort -u); do systemctl status $i; done | grep '●' | awk '{print $2}' | sort -u
Note that there are some issues:
systemctl daemon-reload
should be executed prior to restarting anything else- if PID 1 (
systemd
itself) needs to be restarted, it can be done usingsystemctl daemon-reexec
systemctl restart dbus.service
breaks some other services, they need to be restarted after dbus restart:systemd
itself:systemctl daemon-reexec
systemd-logind
systemd-machined
- probably other systemd-*/other services that (heavily) use
dbus
- If you're connected via SSH and SSH needs to be restarted, but
systemctl restart sshd
won't restart it as long you are connected, I see 2 options:- schedule
systemctl restart sshd
usingat/cron/systemd
timers - restart
SSH
using another remote (secure) shell such asmosh
- schedule
- running
screen/tmux
may also block services likeSSH
from restarting, the easiest way is to close these sessions before restarting services - as told in a previous answer, logout/login may be needed, especially for graphical sessions