小编2rs*_*2ts的帖子

systemd 中的“失败(结果:资源)”是什么意思?

我有一个失败的 systemd 单元,我不确定结果类型应该是什么意思。

Active: failed (Result: resources) since Thu 2016-11-17 21:06:42 UTC; 32min ago
Run Code Online (Sandbox Code Playgroud)

什么Result: resources意思?我很熟悉Result: exit-code,但不是这个。

systemd

6
推荐指数
1
解决办法
1万
查看次数

在其他设备停机前运行脚本

在关闭机器时,我需要在机器上的一组其他服务停止之前运行脚本。(就我而言,终止 EC2 实例。)

我已经尝试了这个问题的答案的变体,但没有任何效果:如何在使用 systemd 关闭时在其他所有内容之前运行脚本?(我也看了 unix.se,但它也不好:https ://unix.stackexchange.com/questions/39226/how-to-run-a-script-with-systemd-right-before-shutdown .. . 我也查看了邮件列表。)

我最大的问题是该问题的 OP 想在卸载某些挂载之前运行脚本,但我对挂载没有任何要求,而是对服务有任何要求。

我的服务是这样的:

[Unit]
Description=Run script before other things stop on shutdown
Wants=multi-user.target network.target foo.service bar.service
After=multi-user.target network.target foo.service bar.service

[Service]
ExecStart=/bin/true
ExecStop=-/my/script
ExecStopPost=/bin/sleep 5s
RemainAfterExit=yes
Type=oneshot

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

我在启动后启用并启动了这个单元,但是当我关闭实例时它似乎没有运行脚本。我不知所措,我该怎么办?

我在 Debian Stretch 上使用 systemd 232。

linux debian shutdown systemd debian-stretch

5
推荐指数
1
解决办法
549
查看次数

标签 统计

systemd ×2

debian ×1

debian-stretch ×1

linux ×1

shutdown ×1