大网数据广告活动
服务器运维问答

How can I predict systemd's shutdown order?

· 52CE 我爱测

Is there a way to get systemd to tell me the rough order in which it will shutdown services when I cleanly shut the whole system down? Since systemd will shut things down in parallel, I appreciate there is no way to know the exac…

问题原文

原帖链接 · Adam Spiers · CC BY-SA 3.0

Is there a way to get systemd to tell me the rough order in which it will shutdown services when I cleanly shut the whole system down? Since systemd will shut things down in parallel, I appreciate there is no way to know the exact order, but it would still be very helpful to know what constraints systemd will impose on the shutdown sequence, preferably in some kind of visualization which is easy to understand.

The motivation is that for development and debugging of service files, it would be a lot more convenient to get this predicted list in advance, rather than having to do a real shutdown and then boot up again and inspect the logs every time I want to determine what impact a change to a service unit file or some other aspect of systemd's configuration will have on the shutdown order.

I was hoping that something like

systemctl list-dependencies --before shutdown.service

would do the job, but it only emits:

shutdown.service

社区高分解答

原帖链接 · ilp68 · CC BY-SA 4.0

Maybe stating the obvious reduces the learning effect, but all I did to get the full list of reverse dependencies for shutdown-target as asked in the original post, was:

systemctl list-dependencies --after shutdown.target

OT: I ran in a problem where the shutdown of a kubernetes system hangs (the machine becomes irresponsive and will not shut down) because the nfs mounts are killed before the actual services have completed shutdown. This question helped me progress.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。