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?


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.

  • 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:


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.