LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-05-2005, 07:20 AM   #1
mikemrh9
Member
 
Registered: Nov 2003
Distribution: Arch
Posts: 136

Rep: Reputation: 21
Understanding K*, S* scripts and runlevels


Hi.

I'm trying to get my head around the scripts in /etc/init.d and am rather confused by the following:

I am running SuSE 9.2, have installed apache2 through YaST, and consequently have the following files available:

/etc/init.d/apache2
/etc/init.d/rc3.d/K08apache2
/etc/init.d/rc5.d/K08apache2

The latter 2 scripts are symlinks to the first.

As I inderstand it, the 'K' prefix should kill the process as I enter/exit runlevels 3 and 5, meaning that the apache2 server should not actually started at all, which seems strange for a fresh install.

However, apache2 does start, and if I do a chkconfig --list, i get the following:

apache2 0;off 1;off 2;off 3;on 4;off 5;on 6;off

Also, if I do an 'init 1' and then chkconfig, the apache2 server is still running, as it is when I then follow it with an 'init 5'.

My questions are as follows:

1. If a script in '/etc/init.d/rcx.d/' is prefixed with a 'K', when should it actually be killed? On entering, exiting the runlevel, or both?

2. If my '/etc/init.d/rc5.d/K08apache2' script has indeed been told to kill '/etc/init.d/apache2', where is apache2 starting from? (There is no 'rc.config' file on my system, which can apparently be used in a SuSE distro to veto startup scripts)

3. Have I actually got hold of the wrong end of the stick with the 'K' and 'S' prefixes? ('K' to kill a process, 'S' to start a process on entry/exit of a particular runlevel)

Mike.

Last edited by mikemrh9; 04-05-2005 at 07:22 AM.
 
Old 04-05-2005, 08:04 AM   #2
Darin
Senior Member
 
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Reputation: 45
For apache to start, there should be somewhere an:
/etc/init.d/rcx.d/Sxxapache2
that symlinks to the /etc/init.d/apache2

If you don't have one of those, then it's possible that it is being started somewhere else.

The way it works AFAIK is that each directory has SxxProcess symlinks that start the processes which are set to run in this runlevel and KxxProcess symlinks that stop the services that should be shut down when leaving this runlevel. When you enter a runlevel, all the kill (K*) scripts from the previous level are run in order of their number and then all the start (S*) scripts for the current runlevel are executed, also in order by their numbers.

reference: http://www.comptechdoc.org/os/linux/...unscripts.html

There are also other scripts that affect startup such as /etc/inittab and the rc.sysinit and you can add commands into rc.local, which gets run last. If something isn't set to start in a given runlevel but it starts anyhow, it's probably somewhere in one of the main scripts, or is being started from another processes' script.

Most distros, and likely SuSE as well although I don't have experience with it, will also usually run the other scripts referenced in generic Linux documentation and if they don't exist you can create them. If that was confusing, what I mean is that if there is say no rc.local you can simply create it in the right directory and it will be used.

If you can't figure out where apache is being started from, and can't find any Sxxapache2 symlinks, try one of these searches:
Code:
grep -R apache /etc/init.d/*
grep -R httpd /etc/init.d/*
I hope that did more to help than to confuse you. I know I initially had problems wrapping my brain around it all, which may explain my preference for Slackware

Last edited by Darin; 04-05-2005 at 08:07 AM.
 
Old 04-05-2005, 08:13 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Look into the YAST runlevel editor. It shows in the expert mode a lot more information than chkconfig, e.g. there is a "boot" runlevel and accordingly the directories at /etc/init.d/*...

Yast also lets you look comfortably at the various system logs.
 
Old 04-05-2005, 08:51 AM   #4
mikemrh9
Member
 
Registered: Nov 2003
Distribution: Arch
Posts: 136

Original Poster
Rep: Reputation: 21
Thanks very much to both of you.

I'm now 99% happy with how this works.

There was indeed a 'S16apache2', which I overlooked before. That will teach me to be more thorough...

Just one small niggle:

Why did apache continue to run when I entered runlevel 1? I would have expected 'K08apache2' to kill it as I left runlevel 5, and there appears to be no script to restart it in runlevel 1.

Mike.
 
Old 04-05-2005, 09:00 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Search in the documentation for "The SuSE boot concept". Here is a nice general account of what is done how and where. You only have to follow the scripts (/sbin/init, /etc/inittab and their ilk and who they call ) to see for yourself.

Central feature is a loop which parses the runlevel number against the directory names and calls the therein contained links while making sure that no unnecessary scripts are called...
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Runlevels nin881 Slackware 8 05-21-2005 02:50 AM
I messed up my runlevels jjorloff1 Linux - General 14 08-17-2004 04:35 PM
RunLevels bcom Mandriva 3 05-31-2004 07:07 PM
runlevels? Computergirl24 Linux - Software 4 12-26-2003 04:45 PM
runlevels kriver Linux - General 1 03-13-2002 05:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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