Welcome to the most active Linux Forum on the web.
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 10-30-2002, 09:45 PM   #1
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
could use some help with my init.d script....

hello all... I'm new to this whole daemon thing.. trying to feel my way through. If someone could point me in the right direction, I'd be much appreciative.

I need to start my server program when the machine boots.. I figured it would need to startup at run level 3 & be started at level 4 & 5... the priority is low, so I've made links to this script in rc3, 4, &5.d as S99mlserver and in rc0,1,&2.d as K8mlserver. The script is /etc/init.d/mlserver and looks like this:

# chkconfig: 345 99 8

# See how we were called.
case "$1" in
	# Start up the server
	# Stop the server
	kill -9 martianServer
	# stop it & start it again
	kill -9 martianServer
	# do not advertise unreasonable commands that there is no reason
	# to use with this device
	echo $"Usage: $0 {start|stop|restart|reload}"
	exit 1

exit 0
also... do I need to do anything with chkconfig? should that be run at some point on the command line? Does the fact that something else starts with S99 screw up the startup? I assume that when the machine starts up, it runs through the rc#.d for each of the links as "link start" (in other words it passes the "start" argument to the linked script) - is that right? Is kill -9 a good way to stop the program, or is that bad form?

and help would be great.. thanks.
Old 10-30-2002, 11:21 PM   #2
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
the S99 is relative to when it starts, so I guess you answered that yourself, the consideration is when do you want it to start in the sequence, maybe considering networking, firewall, etc. they don't need to be a unique number.

[root@www init.d]# chkconfig --list scriptname will show you what's setup

[root@www init.d]# chkconfig --list squid
squid 0:off 1:off 2:off 3:on 4:on 5:on 6:off

if it's links are not in the runlevels I can do

[root@www init.d]# chkconfig --add squid

[root@www init.d]# grep chkconfig squid
# chkconfig: - 90 25

the script contains the settings for chkconfig to use. so the links will be created

on this one the runlevels are set in the script as well

[root@www init.d]# grep chkconfig syslog
# chkconfig: 2345 12 88

you can use chkconfig to set one up like this...

some examples..

[root@www init.d]# chkconfig --list squid
squid 0:off 1:off 2:off 3:on 4:on 5:on 6:off

[root@www init.d]# chkconfig --level 2345 squid on

[root@www init.d]# chkconfig --list squid
squid 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@www init.d]# chkconfig --level 2 squid off

[root@www init.d]# chkconfig --list squid
squid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Old 10-31-2002, 02:33 AM   #3
Senior Member
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Does the kill -9 processname actually work? Depending on how your scripts are start up there should be helper functions around for starting and stopping daemons. Usually something like startproc and stopproc. They usually create a file with the pid of the daemon in /var/run. This pid is used to kill the daemon properly. One thing you shouldn't forget is that if you don't shut down properly the pid file won't get removed. So if you haven't setup your scripts properly to clear these files then your daemon would probably not start on the next boot.
But you should look at the other scripts there should be plenty of examples of how it's done.
Old 10-31-2002, 07:21 PM   #4
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
thanks guys... that was what I needed.


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
How to write init script shahrokhnikou Programming 4 10-24-2005 03:08 PM
Adding to init script djgblz Linux - Newbie 4 07-28-2005 10:12 AM
can't get my init script working nukeu666 Linux - Newbie 4 12-16-2004 11:12 AM
how do i add my script in init nukeu666 Linux - Newbie 1 08-16-2004 07:56 AM
help with init script output ierickson Linux - General 0 05-07-2004 12:05 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:45 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
Open Source Consulting | Domain Registration