LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Adding to /etc/rc.d/rc3.d (https://www.linuxquestions.org/questions/linux-newbie-8/adding-to-etc-rc-d-rc3-d-822629/)

anon091 07-28-2010 09:02 AM

Adding to /etc/rc.d/rc3.d
 
I read that if you issue the following two commands in /etc/rd.c/rc3.d that lampp will automatically restart itself when you restart a server. Could someone explain why this works? I under ln makes a link to the lampp executable, but I'm sure there's some magic behind the odd looking names of the links you're creating.

ln -s /opt/lampp/lampp S99lampp
ln -s /opt/lampp/lampp K01lampp

AlucardZero 07-28-2010 09:06 AM

It's the System V init process.

From /etc/rc3.d/README on my Debian system:

Quote:

The scripts in this directory are executed each time the system enters
this runlevel.

The scripts are all symbolic links whose targets are located in
/etc/init.d/ .

To disable a service in this runlevel, rename its script in this directory
so that the new name begins with a 'K' and a two-digit number, where the
number is the difference between the two-digit number following the 'S'
in its current name, and 100. To re-enable the service, rename the script
back to its original name beginning with 'S'.

For a more information see /etc/init.d/README.
What happens is the rc process calls /etc/rc.d/rc3.d/S* scripts with argument "start" in order of the number in their names. Similarly K scripts are passed "stop".

sem007 07-28-2010 09:09 AM

/etc/rc.d/rcX.d directory contain scripts which are execute at boot time or at runlevel changing.

if script name start with S it means script/service start at boot time.
if script name start with K it means script/service stop/kill at boot time.

if you want to start lampp service in runlevel 3 then create link with S

HTH

anon091 07-28-2010 09:11 AM

OK, I understand the S ones now. But does it call the K ones during a shutdown, and that's why you create them also?

anon091 07-28-2010 09:12 AM

Thanks sem007, you answered the question in my post when I was replying to Alucard. K's are called during shutdown. Makes sense, and I understand the reason behind the numbering pattern too, pretty clever!

sem007 07-28-2010 09:17 AM

K script execute at shutdown or when you change run level.

for just an example if you set postfix link K100postfix in runlevel3 and when you switch any runlevel to runlevel 3 it means postfix service stopd.

when you shutdown or restart system scripts of /etc/rc.d/rc0.d will execute and all script links (exclude killall and halt) start with K

you can compare it yourself

Code:

ls -l /etc/rc.d/rc3.d
ls -l /etc/rc.d/rc0.d

HTH


All times are GMT -5. The time now is 05:25 PM.