从systemd.unit(5)
,该选项Requires=
意味着:
配置对其他单元的需求依赖。如果该单位被激活,此处列出的单位也将被激活。如果其他单元之一被停用或激活失败,则该单元将被停用。
我对此做了一个小实验。我创建了 2 个服务:a.service
和b.service
:
# cat a.service
[Service]
ExecStart=/bin/false
# cat b.service
[Unit]
Requires=a.service
[Service]
ExecStart=/bin/sleep 1000
Run Code Online (Sandbox Code Playgroud)
我做了之后
systemctl start b.service
我期望看到双方a.service
和b.service
失败,因为a.service
失败/bin/false
和b.service
失败,a.service
失败。
但是,b.service
正在运行:
root@john-ubuntu:/etc/systemd/system# systemctl status a.service b.service
? a.service
Loaded: loaded (/etc/systemd/system/a.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-09-07 16:38:39 CST; 2s ago
Process: 1245 ExecStart=/bin/false (code=exited, status=1/FAILURE)
Main PID: 1245 (code=exited, …
Run Code Online (Sandbox Code Playgroud) 我想开发一个应用程序并想nice
为我的守护进程提供一个值。但我没有找到这方面的指导方针。
有些文章说备份任务应该有更高的nice
价值(意味着更低的优先级),但我找不到什么样的进程应该有更低的nice
价值。
如果没有这样的设置nice
值指南,那么每个守护进程都将其nice
值设置为-20
,这是最高优先级,这难道不是一个可怕的世界吗?