Centos – daemon function isn’t working in CentOS 6.4

centoscentos6daemon

I'm trying to daemonize a process under a different user.

In my init.d, I have a service which looks a little bit like this:

...
start() {
    echo "Starting mydaemon..."
    daemon --user someuser --name mydaemon mycommand
}
...

(entire script here: http://pastebin.com/bvpnsHgn)

However, all I get is daemon: command not found.

I checked that daemon() is declared in /etc/init.d/functions, but still, I cannot seem to use it.

How can I resolve this?

Best Answer

Did you make sure to source the /etc/init.d/functions library in your service's init.d script?

You'd need this in your init.d script:

# Source function library.
. /etc/init.d/functions

If this is already there, can you please post your daemon's start script?