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?

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?

  • I added that line, and it still does the same. I don't follow what you want me to paste? The entire file I gave the snippet from? – CJxD Nov 30 '13 at 23:05
  • 1
    @CJxD Yep. Please do so. – ewwhite Nov 30 '13 at 23:19
  • pastebin.com/bvpnsHgn – CJxD Nov 30 '13 at 23:22
  • @CJxD I'm sorry. Can you try this with . /etc/init.d/functions, as I wrote in my answer? – ewwhite Nov 30 '13 at 23:26
  • 1
    Nevermind! It did work, the file just wasn't uploading to the server when I saved it. D'oh! – CJxD Nov 30 '13 at 23:31
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.