标签: pidfile

pid 和 lock 文件有什么用?

我经常看到程序指定pid和lock文件。而且我不太确定他们做什么。

比如编译nginx的时候:

--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
Run Code Online (Sandbox Code Playgroud)

有人可以对此有所了解吗?

lock pidfile

93
推荐指数
3
解决办法
10万
查看次数

start-stop-daemon 使用错误的 pid 生成 cron pidfile

我有一个 init.d 脚本来启动 crond,它为 start() 指定以下内容:

start-stop-daemon -S --quiet --make-pidfile --pidfile /var/run/crond.pid --background --exec /usr/sbin/crond
Run Code Online (Sandbox Code Playgroud)

但是,PID始终比 /var/run/crond.pid 中记录的数字高一个数字。有谁知道这里发生了什么?我有大约十个其他 init.d 脚本也进行相同的调用,只有 cron.d 有这个问题。

编辑: 这很有趣:

# /usr/sbin/crond &
#
[1]+  Done                       /usr/sbin/crond
# echo $!
737
# ps -eaf | grep crond
738 root     /usr/sbin/crond
740 root     grep crond
#
Run Code Online (Sandbox Code Playgroud)

cron services pidfile

4
推荐指数
1
解决办法
4615
查看次数

在“后台”运行进程到底意味着什么?

我想更好地了解什么是后台进程。阅读这行代码后,问题就出现了:

/usr/sbin/rsyslogd -niNONE &
Run Code Online (Sandbox Code Playgroud)

来源

文件说:

  -i pid file
         Specify an alternative pid file instead of the default
         one.  This option must be used if multiple instances of
         rsyslogd should run on a single machine. To disable
         writing a pid file, use the reserved name "NONE" (all
         upper case!), so "-iNONE".

  -n     Avoid auto-backgrounding.  This is needed especially if
         the rsyslogd is started and controlled by init(8).
Run Code Online (Sandbox Code Playgroud)

来源

& 符号&似乎意味着请求该命令在后台运行,例如参见此处

如果我的理解是正确的,pid 文件与 daemons 一起使用,即程序在后台运行时。 …

job-control pidfile background-process

0
推荐指数
1
解决办法
1327
查看次数

标签 统计

pidfile ×3

background-process ×1

cron ×1

job-control ×1

lock ×1

services ×1