Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-11-2008, 09:54 AM   #1
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Rep: Reputation: 15
How to use the daemon function in /etc/rc.d/init.d/functions


I have a server program that is automatically started at startup. In my startup script I simply call the program. However, I would like a) to do things in as standard a way as possible b) have it verified that my program started by having a nice green [OK] at the right of the screen like everything else does.

I'm pretty sure I should be using the daemon function in /etc/rc.d/init.d/functions, but I can't find any documentation. Is it what I should be using and can anyone point me to a good manual or HOWTO, please?

The following is total guesswork. I think the daemon function will give me a nice green [OK] but it needs my program to store its pid in a file so that it can find the pid and know that my program has started. Am I right? If so, where does the pid file reside (typically if I do things in as standard way as possible)?

Is there anything else I need to know about using the daemon function?


Old 09-12-2008, 04:32 AM   #2
Registered: Jun 2008
Location: Toronto, Canada
Distribution: SuSE, RHEL, Mageia
Posts: 132

Rep: Reputation: 17
Some urls that could be useful for you.
Old 09-12-2008, 04:53 AM   #3
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Original Poster
Rep: Reputation: 15
Originally Posted by Vit77 View Post

Thank you. However, neither of these resources tell me what I need to know.

The first gives an example that uses daemon, but the only information it gives is
The bash script functions daemon, killproc and status can all be found in the script /etc/rc.d/init.d/functions.
The second (which I came across earlier during my extensive Googling) also gives an example but is infuritaing in that it says
The three functions I use in my script are killproc, status, and daemon. You have to be careful that you know both what the functions do, and what your application's default behavior is.
but doesn't give us that information or a link to where it can be found. It does give a snippet of info
For example, the function that attempts to grab the PID of the running process, pidofproc, assumes that the process writes a pid file somewhere under /var/run.
but even that's incomplete. "Somewhere under /var/run"? Not complete documentation. My question is: where is the complete documentation?

Old 09-12-2008, 05:33 AM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
pidofproc has a manpage. According to the manpage on my system, it checks for /var/run/<basename>.pid unless you supply the -p option to check a different location. If on your system, pidofproc is a bash function, it may be a wrapper that also looks in a directory, such as for /var/run/${basename%d}/${basename}.pid. You will need to read it to be certain. A functions script in /etc/init.d/ will probably be distro dependent. If there is a standard reference, you may try the Linux Standard Base. Also grep for function being called in scripts in /etc/init.d/. The usage will probably show you everything you want to know about the function.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
init-functions not found? MHaahr Debian 1 11-03-2007 04:52 AM
Slack equivalent of status, daemon and killproc from RH init.d/functions MQMan Slackware 1 07-26-2007 05:31 PM
how to use daemon function blackzone Programming 1 12-14-2004 03:59 AM
/etc/rc.d/init.d/functions? ccajina Slackware 4 11-26-2003 04:05 PM
daemon function hvdwatt Linux - General 1 06-15-2003 07:19 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:03 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration