I found lots of good documentation for ubuntu's start-stop-daemon and there is a man page for a binary daemon
.
But from what I can tell the canonical way to start a daemon in a rhel/centos script is to source /etc/init.d/functions
then use the daemon()
function. But I can't find any good examples or documentation.
What is the canonical way to start a daemon in rhel/centos-6 init script?
my first attempt was:
#!/bin/bash
source /etc/init.d/functions
daemon --user USER nohup /path/to/your/binary arg1 arg2 >/dev/null 2>&1 &
Best Answer
The documentation and example you are looking for is located at
/usr/share/doc/initscripts-*/sysvinitfiles
on CentOS/RHEL. Here is the documentation for thedaemon
function specifically:With CentOS/RHEL 6, you also have the option of using an upstart job file instead of writing a sysv init script.