Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

/etc/rc.d/rc

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
Hello,
On AIX 5.2 there is the following script executed in level 2 (/etc/rc.d/rc):

l2:2:wait:/etc/rc.d/rc 2

#############################################################
# file name: rc
# purpose: run user-provided scripts in rc directories
#############################################################

#run level parameter
run_level=${1}

#check if valid run level was requested

case "$run_level"
in
[01] ) echo "Invalid run level choice; levels 0 and 1 are reserved in AIX ";;
[a-zA-Z] ) echo "Please enter a run level from 2 to 9";;
esac

#check if run level directory exists
if [[ -s /etc/rc.d/rc${run_level}.d ]] then

#get a list of the "kill" scripts in this directory
k_list=$(ls /etc/rc.d/rc${run_level}.d | grep "^K" | sort -)

#get a list of the "start" scripts in this directory
s_list=$(ls /etc/rc.d/rc${run_level}.d | grep "^S" | sort -)

#execute "kill" scripts
if [[ -n ${k_list} ]] then
echo "${k_list}" | while read item
do
/etc/rc.d/rc${run_level}.d/${item} stop
done
fi

#execute "start" scripts
if [[ -n ${s_list} ]] then
echo "${s_list}" | while read item
do
/etc/rc.d/rc${run_level}.d/${item} start
done
fi


else
echo "Requested run level directory does not exist"
fi

exit 0




Does it execute stop and start scripts together every system start and stop? I would expect /etc/rc.d/rc2.d/S55app (/etc/rc.d/init.d/app start)being run on system start and /etc/rc.d/rc2.d/K45app (etc/rc.d/initd./app stop) being started on system shutdown.


regards, m.

 
Hi,
This script receives a run level as parameter, say 2

First, this script collects all scripts named K* (KILL) in the run-level directory received as parameter (/etc/rc.d/rc2.d for run level 2) and it calls them with the parameter 'stop'
Then, it collects again all scripts starting with 'S'(START) in the run-level directory and it calls them with the parameter 'start'

When you type in the command /etc/telinit 2 at shell prompt or when the system is rebooted :
- all the K* scripts in /etc/rc.d/rc2.d are executed and
- all the S* scripts are executed too.
 
does it mean the a script "app" is executed twice during the starting system and twice during shutting down system?

1st stopping
2nd starting

????

For me it is not OK.

r, m.

 
Hi,
Here is a concrete example:

The posted script is called rc.uagent and located at my box in /etc/rc.d/documentum ( it could be located in any other directory)

#### begin of script ######
#!/bin/ksh
#------------------------------------------------------------
#
# @(#) name : rc.uagent
# @(#) source : /etc/rc.d/documentum
# @(#) objectif : script to start and stop arcserve agent
# @(#) This file is linked with the two files :
# @(#) /etc/rc.d/rc2.d/K20_agentsauvegarde
# @(#) /etc/rc.d/rc2.d/S20_agentsauvegarde
#
#-----------------------------------------------------------
case "$1" in
start )
/usr/uagent/uagent start
;;
stop )
/usr/uagent/uagent stop
;;
* )
echo "Usage: $0 (start | stop)"
exit 1
;;
esac

#### end of script ######

In th directory /etc/rc.d/rc2.d, I have linked two file
K20_agentsauvegarde and
S20_agentsauvegarde
because when the system is at run level 2,I want to stop the agent before restarting It.

If I just want to start it, my /etc/rc.d/rc2.d would contain only S20_agentsauvegarde which is called from rc script with 'start' parameter.


 
thx for your reply.

I have the same you wrote. One script and 2 links to it: /etc/rc.d/rc2.d/S45app and /etc/rd.d/rc2.d/K55app

I need the following:

Stop the app when system is leaving the level 2 (for example. system shutdown). (only stop the app).

Start the app when system is entering the level 2. (only start).

So what system does when I shutting down the system?
In my opinion, having default /etc/rc.d/rc in AIX 5.2 it runs "stop" and "start" the app one by one - and should only stop!

thx in adv, m.
 
ogniemi,
it's absolutely normal it's the standard startup way in Unix System V, SCO and some others
 
Hi,
I have used run level 3 to bring my application up
In run level 2, I start oracle listener, Documentum broker and Arcserve agent, a script to stop my application and a script of me that checks if I come from run level 'S', I bring the system to run level 3 with
/etc/telinit 3

When the system boot up, it runs automatically run level 2
and goes up to run level 3 with my script.

When I want to shutdown the system, I first issue /etc/telinit 2 whitch stops the application( and restarts all others but still in run level 2)
after this I issue a classical shutdown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top