Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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

https://gist.github.com/Radamanf/7152723

share|improve this answer
add comment

Your Answer

 
discard

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.