gpt4 book ai didi

linux - 创建 Linux Pidfile

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:45:34 25 4
gpt4 key购买 nike

操作系统是Centos7

如何通过命令创建pid文件?

. /etc/rc.d/init.d/functions
#cmd to createin /var/run/example/
daemon --user $USER --pidfile $pidfile "$DAEMON" start

但是没有创建 pid。

有什么建议吗?

最佳答案

--pidfile 用于检查守护进程是否已经运行。在 RHEL(和派生)上,守护进程函数不会写入 pidfile。

您也不能将 $! 与守护进程一起使用来获取 pid。所以你必须执行以下命令从进程列表中获取 pid

ps -ef | grep -v grep | grep YOUR_PROCESS_NAME | awk '{ print $2 }' > pidfile

如果你想使用守护进程。

您还可以使用其他工具,例如 this这将生成 pid 文件。

关于linux - 创建 Linux Pidfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37597369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com