登入 Ubuntu 時,常會看到最底下會有一行字,提醒你主機是否需要重新開機:
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-142-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 packages can be updated.
0 updates are security updates.
*** System restart required ***
追了一陣子,才知道判斷的方法非常簡單,只要到 /var/run 目錄下檢查是否有「reboot-required」的檔案即可。
例如:
$ ls /var/run
acpid.pid crond.reboot initctl log motd.dynamic resolvconf snapd.socket udev
acpid.socket dbus initramfs lvm mount rsyslogd.pid sshd unattended-upgrades.lock
agetty.reload dhclient.enp0s3.pid init.upgraded lvmetad.pid mysqld screen sshd.pid user
atd.pid dmeventd-client irqbalance.pid lxcfs network sendsigs.omit.d sudo utmp
blkid dmeventd-server iscsid.pid lxcfs.pid reboot-required shm systemd uuidd
crond.pid grub lock mdadm reboot-required.pkgs snapd-snap.socket tmpfiles.d xtables.lock
就這樣,沒了。