LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-11-2008, 08:54 AM   #1
lostjohnny
Member
 
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


Hi,

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?

TIA

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

Rep: Reputation: 17
Some urls that could be useful for you.

http://www.yolinux.com/TUTORIALS/Lin...itProcess.html
http://www.linux.com/feature/46892
 
Old 09-12-2008, 03:53 AM   #3
lostjohnny
Member
 
Registered: May 2006
Distribution: Fedora Core 6
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
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
Quote:
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
Quote:
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
Quote:
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?

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

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
  


Reply



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 03:52 AM
Slack equivalent of status, daemon and killproc from RH init.d/functions MQMan Slackware 1 07-26-2007 04:31 PM
how to use daemon function blackzone Programming 1 12-14-2004 02:59 AM
/etc/rc.d/init.d/functions? ccajina Slackware 4 11-26-2003 03:05 PM
daemon function hvdwatt Linux - General 1 06-15-2003 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:57 AM.

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