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
).
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
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.