LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 05-09-2011, 12:41 AM   #1
BeefyElbow
LQ Newbie
 
Registered: Jul 2009
Posts: 5

Rep: Reputation: 1
Question RedHat: Daemons


Hi all,

I've inherited a RedHat system, and I'm trying to control some daemons using the classic start and stop mechanism.

I'm having problems understanding when and where the PID is written to the PID file. I'm not sure if the file I pass in is being used.

I've created a startup script in /etc/init.d called daemoncontrol.
Here's a snippet from the 'start' section of my daemoncontrol:

Code:
PID_FILE=/var/log/daemontest1.pid

daemon  --pidfile="$PID_FILE" '/bin/launchmgr --daemon "daemontest1 -d 127.0.0.1"'
I've got an app called 'launchmgr' that expects some parameters, one of which is my daemon application (daemontest1).

I'm expecting here that the PID of the launchmgr instance will be written to the specified PID file. This doesn't appear to be the case. Instead, the PID seems to be written to /var/run/launchmgr.pid instead, as if it's always using the base of the application. Where does this happen?

I've ploughed through /etc/init.d/functions and it's not in there.

Kernel 2.6.18-164.el5
 
Old 05-09-2011, 03:13 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
The standard for PID files is actually /var/run/

/var/log is for log files. Why not just change your app to look for the pid file in /var/run instead? Did you write the program that creates the pid in /var/run?
 
1 members found this post helpful.
Old 05-09-2011, 04:17 PM   #3
BeefyElbow
LQ Newbie
 
Registered: Jul 2009
Posts: 5

Original Poster
Rep: Reputation: 1
Bah! Typo!

The path is set as /var/run/!

That makes the definition of the variable:

Code:
PID_FILE=/var/run/daemontest1.pid
The only part I really don't understand is where the PID file is actually updated with the PID value. Where is that written? Is it some low-level kernel action, or in some other script somewhere. I can't find anywhere in Red Hat's daemon function (/etc/init.d/functions) that writes the PID to the file.

Using echo statements in the 'daemon' function, I can see that my specified PID_FILE is passed through correctly. However, after this section:

Code:
	# And start it up.
	if [ -z "$user" ]; then
	   $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
	else
	   $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
	fi
An incorrect PID File for the basename of the launcher is updated with the PID. Where does this happen?
 
  


Reply


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
Daemons palisetty_suman Linux - Newbie 4 04-19-2009 03:24 PM
daemons cnm Linux - Newbie 4 11-08-2006 08:12 AM
daemons LinuxLala Linux - General 4 11-28-2003 02:37 PM
Daemons mariua Linux - General 0 10-11-2001 06:03 AM
Daemons mariua Linux - Newbie 0 10-11-2001 06:00 AM

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

All times are GMT -5. The time now is 03:14 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration