Re: runlevels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 04 January 2005 18:19, Larry D Sorensen wrote:
> I have 2 scripts that I want to run at different times. One has been
> linked in the /etc/rc3.d directory for startup (S98script). The second is
> to do the opposite and stop things. It is called K11script. If I put the
> kill script in /etc/rc2.d and then manually change run levels, init 2,
> the script does not run. I know the script works, however, because I can
> call it from the command line. Any suggestions?
>
> Larry
okay, let's break this down to the basics...
Are these separate scripts or are they symlinks to the _same_ script?
Do they start and stop the _same_ service?

the way it is supposed to work is this:
every script in /etc/rc.d/init.d should have a symlink pointing to it from 
every runlevel directory (/etc/rc.d/rc?.d/) which will start with either a K 
or an S, followed by 2 digits.
example:
/etc/rc.d/init.d/sshd is the script that starts the ssh daemon.
it has the following symlinks...
/etc/rc.d/rc0.d/K25sshd
/etc/rc.d/rc1.d/K25sshd
/etc/rc.d/rc2.d/S55sshd
/etc/rc.d/rc3.d/S55sshd
/etc/rc.d/rc4.d/S55sshd
/etc/rc.d/rc5.d/S55sshd
/etc/rc.d/rc6.d/K25sshd

notice there is only *one* link in each directory...

when you change runlevels the /etc/rc.d/rc script runs, reads the symlinks by 
name in each subdirectory and does the following:
it looks at the K links and *if* the service that each controls is currently 
running, stops it 
then it does the S links, running them only if the service in question is 
*not* currently running

so with sshd, what it does is see the K25sshd link, check if a service called 
'sshd' is currently running, and if it is, runs /etc/rc.d/init.d sshd stop
if it is not then.

Basically the problem you may be having is that the system sees your K 
script/link, but doesn't see the 'service' (the bit after the K11) as 
currently running, so it doesn't try to stop it...

perhaps the answer would be to combine both scripts into one, which does 
different things when called with a 'start' or a 'stop' argument.

this way you could also add it to chkconfig control so that the start/stop 
parts are more easily manipulated.

one of the things it should do when called with the argument 'start' is
'touch /var/lock/subsys/script'
which is one of the indicators that the rc script uses to decide if a service 
is running or not.

shed any useful light?

Stuart
-- 
Stuart Sears RHCE, RHCX
Man has made his bedlam; let him lie in it.
		-- Fred Allen

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux