Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-10-2006, 08:14 AM   #1
LQ Newbie
Registered: Jul 2006
Posts: 5

Rep: Reputation: 0
CentOS 4 (Fedora Core) init script - create PID file

I am trying to write an init script for a shell script and want to know how I can create a PID file for script. I have noticed that in SuSE, there is a function called startproc that accepts a -p option to create a PID file. I have determined that the Redhat/Fedora equivalent to startproc is exec - but this doesn't have a -p option.
This is the SuSE init script that I found as an example to run my shell script:
# /etc/init.d/syslog2mysql

# Comments to support chkconfig on RedHat Linux
# chkconfig: 235 65 35
# description: A very fast and reliable SQL database engine.

# Provides: syslog2mysql
# Required-Start: $local_fs $network syslog mysql
# Should-Start: syslog mysql
# Required-Stop: $local_fs $network syslog mysql
# Default-Start:  2 3 5
# Default-Stop: 0 1 6
# Short-Description: Start and Stop Syslog2MySQL
# Description: Script to push Syslog data to MySql data base


. /etc/rc.status
case "$1" in
	test -s ${syslog2mysql_pid} && {
	    killproc -p ${syslog2mysql_pid} ${syslog2mysql}
	    echo -n "Re-"
	echo -n "Starting syslog2mysql services"
	startproc -p ${syslog2mysql_pid} ${syslog2mysql} $params
	ps -C -o pid= > ${syslog2mysql_pid}
	rc_status -v
	echo -n "Shutting down syslog2mysql services"
	killproc -p ${syslog2mysql_pid} -TERM ${syslog2mysql} ; rc_status -v
	rm -f ${syslog2mysql_pid}
	echo -n "Checking for service syslog2mysql:"
	checkproc -p ${syslog2mysql_pid}	${syslog2mysql} ; rc_status -v
	echo "Usage: $0 {start|stop|status}"
	exit 1
This is the section I am trying to convert from SuSE to Fedora:

startproc -p ${syslog2mysql_pid} ${syslog2mysql} $params
ps -C -o pid= > ${syslog2mysql_pid}
Another side issue - I am looking for any mapping of functions in SuSE to Fedora that can help me with my init scripts. Example: in Fedora what is the equivalent funtion for rc_status in SuSE.
Old 07-10-2006, 08:22 AM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
have you not tried just looking at the existing scripts? precious few better ways to find out how they do it. there are a bunch of functions that sit in /etc/init.d/functions that wrap most of what you are after.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
starting script, init by copy/create file in (samba) folder? muab Linux - General 7 06-22-2005 06:02 PM
Fedora Core 3 to Centos 4 perroduke cAos 2 05-31-2005 10:45 AM
CentOS vs. Fedora Core sebgate20 Linux - Distributions 7 03-07-2005 01:54 PM
Is there a way to make a program create a pid file? blk96gt Slackware 1 10-29-2004 11:59 AM
How can I create a pid file from a backgournd process that I start? Hackiller Linux - General 3 05-12-2004 02:37 PM > Forums > Linux Forums > Linux - Newbie

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