- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Order of services
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 10:39 AM
03-20-2006 10:39 AM
Order of services
I want to know the order of execution of services in init (when shutdown)
Service A: # chkconfig: 35 98 11
Service B: # chkconfig: 35 99 10
At startup it executes (I know how it works):
1) Service A
2) Service B
At shutdown it execute (I am not sure how it works):
1) ????
2) ????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 11:29 AM
03-20-2006 11:29 AM
Re: Order of services
The last directory of the startup directories.
ls /etc/rc1.d
ls /etc/rc2.d
ls /etc/rc3.d
ls /etc/rc4.d
ls /etc/rc5.d
The order you see of the soft links starting with a capital S. That is the startup order, lowest to highest.
The shutdown order is in reverse from 5 down to 1 and beyond, the soft links starting with a K.
They all soft link to combined shut/start scripts in /etc/init.d
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 12:57 PM
03-20-2006 12:57 PM
Re: Order of services
SEP is right about the structures, but here's a little more.
The different /etc/rcX.d structures are the different available run levels on a system (run levels 0-6 + s & S usually, but Linux actually has 0-9 + s & S). Have a quick look at the comments in '/etc/inittab' and 'man init' as to what the different levels are for.
On RH Linux systems, at the change of init levels, the script '/etc/rc.d/rc' is executed. This is what actually launches the '/etc/rcX.d' scripts in their defined order. This script is defined in '/etc/inittab' as lines starting with 'lX' (where X is the run-level you are changing to).
Now here's where it starts differing between the different varients.
The script files linked to in '/etc/rcX.d' (they are in different places in different unicies) get executed based on their name in that directory, in glob-order.
The quick way to check what that means is to run:
echo /etc/rc6.d/*
It will output a single line listing all of the script files in alphabetical/numerical order.
The standard is to have files starting with uppercase S or K for startup and for kill, followed by two digits, designating their order of execution. So on a RH box, we see something like this (ok, this is from my FC4 box):
# echo /etc/rc6.d/K*
/etc/rc6.d/K01yum /etc/rc6.d/K02haldaemon /etc/rc6.d/K03messagebus /etc/rc6.d/K05anacron /etc/rc6.d/K05atd /etc/rc6.d/K05saslauthd /etc/rc6.d/K10dc_server /etc/rc6.d/K10psacct /etc/rc6.d/K12dc_client /etc/rc6.d/K15gpm /etc/rc6.d/K15httpd /etc/rc6.d/K25sshd /etc/rc6.d/K30sendmail /etc/rc6.d/K30spamassassin /etc/rc6.d/K35cyrus-imapd /etc/rc6.d/K50netdump /etc/rc6.d/K50snmpd /etc/rc6.d/K50snmptrapd /etc/rc6.d/K50xinetd /etc/rc6.d/K56acpid /etc/rc6.d/K60crond /etc/rc6.d/K66mDNSResponder /etc/rc6.d/K67nifd /etc/rc6.d/K72autofs /etc/rc6.d/K74apmd /etc/rc6.d/K74lm_sensors /etc/rc6.d/K74nscd /etc/rc6.d/K74ntpd /etc/rc6.d/K75netfs /etc/rc6.d/K85mdmonitor /etc/rc6.d/K85mdmpd /etc/rc6.d/K87auditd /etc/rc6.d/K87named /etc/rc6.d/K88syslog /etc/rc6.d/K89netplugd /etc/rc6.d/K89rdisc /etc/rc6.d/K90network /etc/rc6.d/K92iptables /etc/rc6.d/K94diskdump /etc/rc6.d/K95kudzu
# echo /etc/rc6.d/S*
/etc/rc6.d/S00killall /etc/rc6.d/S01reboot
This means, when changing to init level 6 (someone issued a 'shutdown -r' or some other 'reboot' command), it will start by executing all the K scripts (kill) with the 'stop' argument. Once they are completed, it will then execute all the S scripts with a 'start' argument.
If you're good at reading through a shell script, you can walk through '/etc/rc.d/rc' to see the actual voo-doo, but here's the guts of it:
## stripped a bit for clarity ##
# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/K??}
[ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
|| continue
# Bring the subsystem down.
action $"Stopping $subsys: " $i stop
done
# Now run the START scripts.
for i in /etc/rc$runlevel.d/S* ; do
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/S??}
[ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
&& continue
# Bring the subsystem up.
if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then
exec $i start
fi
action $"Starting $subsys: " $i start
done
So, if stuff is running, kill it off nicely. Once you've killed everything that asked to be killed, start things which need starting.
In the case of INIT 6, you stop all the services.. As a stop-gag, you then run 'S00killall' which checks other subsystems are running and issues nice stops to them, then 'S01reboot' which does final cleanup, unmounting filesystems, killing off remaining processes, before finally rebooting.
So, in answer to the last question, it shuts things down with the same ordering concept as the start-up.
General rule of thumb for a RH box though. The startup+shutdown in the chkconfig linen should add up to 100.
i.e., gpm: # chkconfig: 2345 85 15
Start at position 85 (i.e. late), finish at 15 (i.e. early).
If you stick to this rule of thumb, then everything should shut down in the dependancy order that they started up in. Keeps it nice and simple.
Have fun!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 12:59 PM
03-20-2006 12:59 PM
Re: Order of services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 01:01 PM
03-20-2006 01:01 PM