I use this script to check if the boot kernel matches the current kernel and if a process is using any old libraries.
#!/bin/bash
get_boot_kernel() {
local get_version=0
for field in $(file /boot/vmlinuz*); do
if [[ $get_version -eq 1 ]]; then
echo $field
return
elif [[ $field == version ]]; then
# the next field contains the version
get_version=1
fi
done
}
rc=1
libs=$(lsof -n +c 0 2> /dev/null | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u)
if [[ -n $libs ]]; then
cat <<< $libs
echo "# LIBS: reboot required"
rc=0
fi
active_kernel=$(uname -r)
current_kernel=$(get_boot_kernel)
if [[ $active_kernel != $current_kernel ]]; then
echo "$active_kernel < $current_kernel"
echo "# KERNEL: reboot required"
rc=0
fi
exit $rc
Sample output:
Xorg: /usr/lib/libedit.so.0.0.63
Xorg: /usr/lib/libgssapi_krb5.so.2.2
Xorg: /usr/lib/libk5crypto.so.3.1
Xorg: /usr/lib/libkrb5.so.3.3
Xorg: /usr/lib/libkrb5support.so.0.1
Xorg: /usr/lib/libzstd.so.1.4.5
# LIBS: reboot required
5.10.8-arch1-1 < 5.10.10-arch1-1
# KERNEL: reboot required
If you only have processes using old libraries you can restart the processes instead of rebooting.