检测挂起的已关闭Ubuntu Server 16.04.1

在systemd之前,曾经有人能够在进程列表中看到关闭进程(例如ps -ef | grep shutdown )。 然而,现在我能找到的最新建议是使用systemctl status ,但我没有运气:

 root@m________a:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial root@m________a:~# shutdown -r 14:00 Shutdown scheduled for Mon 2016-10-10 14:00:00 BST, use 'shutdown -c' to cancel. root@m________a:~# ps -ef | grep "shutdown" root 10584 10508 0 13:44 pts/0 00:00:00 grep --color=auto shutdown root@m________a:~# systemctl status systemd-halt.service ● systemd-halt.service - Halt Loaded: loaded (/lib/systemd/system/systemd-halt.service; static; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-halt.service(8) root@m________a:~# systemctl status systemd-reboot.service ● systemd-reboot.service - Reboot Loaded: loaded (/lib/systemd/system/systemd-reboot.service; static; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-halt.service(8) root@m________a:~# systemctl status systemd-poweroff.service ● systemd-poweroff.service - Power-Off Loaded: loaded (/lib/systemd/system/systemd-poweroff.service; static; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-halt.service(8) 

如果有人能解释我如何能够检测到挂起的计划关闭,以及为什么这样的关闭似乎没有显示出使用systemctl我将非常感激

您可以使用

 cat /run/systemd/shutdown/scheduled 

这已添加到systemd 220版本中,如下所述: https ://www.phoronix.com/scan.php?page = news_item&px = Systemd-Kill-Shutdownd

 systemctl status systemd-shutdownd.service 

服务手册页 :

systemd-shutdownd.service是一个实现计划关闭的系统服务,由shutdown(8)公开。 systemd-shutdownd.service会根据请求自动激活,并在未使用时自行终止。


不活动时:

 $ systemctl status systemd-shutdownd.service ● systemd-shutdownd.service - Delayed Shutdown Service Loaded: loaded (/lib/systemd/system/systemd-shutdownd.service; static; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-shutdownd.service(8) 

活动时:

  $ sudo shutdown +100 Shutdown scheduled for ma 2016-10-10 17:12:56 CEST, use 'shutdown -c' to cancel. $ systemctl status systemd-shutdownd.service ● systemd-shutdownd.service - Delayed Shutdown Service Loaded: loaded (/lib/systemd/system/systemd-shutdownd.service; static; vendor preset: enabled) Active: active (running) since ma 2016-10-10 15:32:56 CEST; 3s ago Docs: man:systemd-shutdownd.service(8) Main PID: 3129 (systemd-shutdow) Status: "Shutting down at Mon 2016-10-10 17:12:56 CEST (poweroff)..." CGroup: /system.slice/systemd-shutdownd.service └─3129 /lib/systemd/systemd-shutdownd okt 10 15:32:56 x systemd[1]: Started Delayed Shutdown Service. okt 10 15:32:56 x systemd[1]: Starting Delayed Shutdown Service... okt 10 15:32:56 x systemd-shutdownd[3129]: Shutting down at Mon 2016-1... Hint: Some lines were ellipsized, use -l to show in full.