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

Systemd drop-in fails to create PID file

· 52CE 我爱测

I have a drop-in for systemd-machined at the path /etc/systemd/system/systemd-machined.service.d/10-machined-pid-file.conf . when I run systemctl status systemd-machined I do see the lines Drop-In: /etc/systemd/system/systemd-mac…

问题原文

原帖链接 · Christian Grabowski · CC BY-SA 3.0

I have a drop-in for systemd-machined at the path /etc/systemd/system/systemd-machined.service.d/10-machined-pid-file.conf. when I run systemctl status systemd-machined I do see the lines

Drop-In: /etc/systemd/system/systemd-machined.service.d
       └─10-machined-pid-file.conf

However, I do not see a PID file in /var/run/. Which based on my drop-in:

[Serivce]
PIDFile=/var/run/machined.pid

I believe there should not be any issue creating that PID file. Is there something I am missing?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 3.0

The PIDFile= setting does not create a PID file. That is still up to the service itself to do, the same as it has been for the last 40 years. Rather, this option tells systemd where to find an existing PID file (if any). In most cases it's not required at all, as systemd will keep services in their own cgroups and does not need a PID file to keep track of them. However, systemd will delete a PID file when the service exits, if the service fails to clean up after itself.

From the documentation:

Takes an absolute file name pointing to the PID file of this daemon. Use of this option is recommended for services where Type= is set to forking. systemd will read the PID of the main process of the daemon after start-up of the service. systemd will not write to the file configured here, although it will remove the file after the service has shut down if it still exists.

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

资料来源与适用范围

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

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

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