RedHat的守护程序函数的用法 [英] RedHat daemon function usage

查看:103
本文介绍了RedHat的守护程序函数的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的码头一个初始化脚本在RHEL上。尝试使用后台由init库提供的功能( /etc/rc.d/init.d/functions )。

I'm working on an init script for Jetty on RHEL. Trying to use the daemon function provided by the init library (/etc/rc.d/init.d/functions).

我发现这个简短的文档和的an在线例如(我也一直在该系统上的例子寻找其他的init脚本)。

I found this terse documentation, and an online example (I've also been looking at other init scripts on the system for examples).

看这个片段从网上启动守护进程

Look at this snippet from online to start the daemon

daemon --user="$DAEMON_USER" --pidfile="$PIDFILE" "$DAEMON $DAEMON_ARGS &"
RETVAL=$?
pid=`ps -A | grep $NAME | cut -d" " -f2`
pid=`echo $pid | cut -d" " -f2`
if [ -n "$pid" ]; then
        echo $pid > "$PIDFILE"
fi

何必仰视 $ PID 并用手将它们写入 $ PIDFILE ?我想我知道什么是点的 - pidfile进程文件选项到后台函数

Why bother looking up the $PID and writing it to the $PIDFILE by hand? I guess I'm wondering what the point of the --pidfile option to the daemon function is.

推荐答案

要回答你猜,你有问题,就是 - pidfile进程文件用于检查羯羊守护进程已经在运行。在RHEL(及衍生物)的后台功能不会写pidfile进程文件。

To answer the question you guess that you have, is that --pidfile is used to check wether the daemon process is already running. On RHEL (and derivates) the daemon function won't write the pidfile.

在该程序停留在它必须通过附加被显式发送到背景中的前景的情况下&放大器; 来的命令和PID必须被随后取出。 $!使用后台

In the case that the program stays in the foreground it has to be explicitly sent to the background by appending & to the command and the pid has to be fetched afterwards. $! is not usable when using daemon.

这篇关于RedHat的守护程序函数的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆