8

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?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
Chris Watts
  • 265
  • 1
  • 3
  • 11

2 Answers2

11

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?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
1

If you are missing the scripts, you can simply (re)install them this should get daemon: command not found issue resolved

yum install -y initscripts

Hope this helps

  • 1
    It is conceivable that a system could be messed up in a way where that command would help. It is however not a very likely explanation. The older answer provides a much more likely explanation of the symptoms (and it turned out to be the correct one). – kasperd Nov 28 '16 at 21:10