Re: running a shell script in the init file

Ian Burrell <[email protected]>
Newsgroups gmane.org.user-groups.linux.pdxlug
Message-ID <[email protected]>
Kevin Williams wrote:
> 
> Thanks for all the responses--they were very helpful.  Since I'm
> installing this for a client who has very little linux experience, but
> does have funds to have purchased a license agreement, I have decided to
> stick with the "Redhat" way.  More likely to get support if anything
> happens in the future.
> 
> With that being said, I was able to successfully create the daemons I
> needed.  Having done this I did come up with a couple of questions where
> I was hoping to get clarification:
> 
> 1.  Within the init scripts, after all the setup, the actual start
> command (where the executable is) was always prefaced with the word
> "daemon", like: daemon $INIT_PROG $INIT_OPTIONS  Does anyone know what
> the word daemon is for?
> 

daemon is a function defined in /etc/rc.d/init.d/functions.  It starts 
the program including checking for pid files and logging.

> 2.  In all other scripts, the command is called without the & at the end
> of the line.  Mine runs a perl script and a bash shell.  The bash shell
> I was forced to put the & in so that the startup process didn't hang. 
> Do most of the executables do this by default, and are therefore not
> needed?  The perl script had a -detach option, so the & wasn't needed. 
> Is that how most daemon programs run, or is there some other way that
> I'm missing that forces the application to run in the background (not
> hang when calling /etc/init.d/[app] start)?
> 

Most daemon programs handle putting themselves in the background and 
detaching from the terminal.  If your script has a -detach option, you 
probably should use that if it works.  Otherwise, using "&" for the 
background should work.  You will have to worry about making sure the 
stdout and stderr are redirected.  The daemon function does handle this.

  - Ian

-- 
[email protected]
http://www.znark.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.