Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to create a daemon using /etc/init.d/myservice and it will call a shell script that contains nohup within the script line.

Will it affect it if I could do service stop later?

share|improve this question
up vote 5 down vote accepted

Nohup just blocks SIGHUP. The rc script to start or stop your daemon could use any signals at all to shut down your process.

This link has a good overview of the things a daemon process needs to do on startup, for example closing stdin, stdout and stderr, detaching itself from the parent and getting a new process group and setting up signal handlers.

share|improve this answer
I had managed to throw in nohup within the shell script and the start up part works OK. But when i do /sbin/service myservice stop, the following output shown on the screen even the service did stopped successfully. /sbin/service: line 66: 19466 Terminated env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} – d4v1dv00 Sep 29 '11 at 9:49
Incidentally, a lot of daemons nowadays interpret SIGHUP as a command to reload their configuration files. This might be a better use for it than nohup. – Shadur Sep 29 '11 at 10:16
Your wrapper script should redirect stdout and stderr to a log file, and a daemon process should close stdin, stdout and stderr anyway. See the edit for a link to the ins and outs of writing a daemon process. – ConcernedOfTunbridgeWells Sep 29 '11 at 14:40

You can check this script I wrote recently, it should help:


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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