LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-05-2006, 01:08 PM   #1
techie_techie
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
Why pid file is needed for service in linux?


Hi,

Just some questions from a linux newbie about service files.
For example I was looking at sshd service file.

Q-1. What is the use of service.pid file like sshd.pid? Why I need to write PID inside this file?
Q-2 I am writing a service file for Jboss Server and when I issue restart command for the service, I encountered the race problem (I grep the PID and write into the PID file and in case of restart two PID appear in the PID file instead of one ). Restart in my case is:
restart)
stop
start
if I put a sleep of 3 then it works fine. But just wondering is the only solution or do need to do something else to avoid race?

TIA,
Sachin
 
Old 01-05-2006, 06:01 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Q-1. initscripts (or rather functions in /etc/rc.d/init.d/functions) rely for some part on being able to read the current process ID from the file.
Q-2. Why re-invent the wheel? :-]
 
Old 01-05-2006, 06:27 PM   #3
techie_techie
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for reply..

Q-1: is it a must to write a .pid file manually?

Q-2: I did get that script but it doesn't have PID file handling.So I am finding the PID and writing in PID file.
PID=`ps -ef | grep org.jboss.Main | egrep -v grep | awk '{print $2}'` and the write this into the .pid file. is this the correct way?

Q-3: putting sleep is okay in restart case?

TIA
 
  


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
httpd service stop fails, no pid, this after latest update squadja Red Hat 2 08-11-2004 02:29 PM
/var/run/[XXX].pid - Tcl pid code liguorir Linux - Software 1 05-20-2004 10:32 PM
Is the PCMCIA service needed? IgD Linux - General 3 03-09-2004 10:13 AM
/service/qmail-send/log: up (pid 1924) 20682 seconds, want down fuzzyash Linux - Software 0 02-18-2004 08:42 PM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

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

All times are GMT -5. The time now is 02:24 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