Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Showing results for 
Search instead for 
Did you mean: 

which runlevel should I place my DB2 shutdown scripts?

Go to solution
Yvonne Chan

which runlevel should I place my DB2 shutdown scripts?

I had created a DB2 shutdown scripts and place it at runlevel 2 & 1 but it does not seems to be able to shutdown DB2 database. The error message told me that the process had already been killed. As I understand that under AIX environment, the script is place inside /etc/rc.shutdown. Is there any equivalent place at HP-UX? Thanks.
Michael Tully
Honored Contributor

Re: which runlevel should I place my DB2 shutdown scripts?

Given there are a number of run levels, you
should move your database and application
levels to at least 3 for stopping and 4 for
starting. If you have the database shutdown
script run in these areas you shutdown your
database before anything else and start it
last. Make sure that you also alter the
/etc/inittab file run level to 4 if you
choose to do this and run 'init q' if once
you completed your modification to the file.

/sbin/init.d holds the scripts, with
symbolic links to the
various run level directories.

/sbin/rc.4.d/S990dbstart linked to
/sbin/rc3.d/K010dbshut linked to

The scripts should have case statements for
start/stop within them. There are a number
of examples in /sbin/init.d that can be used.
Anyone for a Mutiny ?
S.K. Chan
Honored Contributor

Re: which runlevel should I place my DB2 shutdown scripts?

You mean you put the shutdown script in 2 run level locations ? That's probably why you got the error that the process had been killed because the shutdown script will try to run again in a lower run level. In HP-UX first you put your script in /sbin/init.d and the best thing for you to do is use the file "template" in /sbin/init.d to model your DB2 startup/shutdown processes. Then you would create a symbolic link ..
To startup (at run level 3 if you want it there)
# cd /sbin/rc3.d
# ln -s /sbin/init.d/db2init S999db2start
===> Assuming S999 is the last start sequence number.
To shutdown (at run level 2)
# cd /sbin/rc2.d
# ln -s /sbin/init.d/db2init K099db2shut
===> Assuming K099 is the first start sequence number.

Finally if you look at the generic "template" file it has a control variable that enable you to disable/enable the script and that file will be place in /etc/rc.config.d

Hope this helps.
S.K. Chan
Honored Contributor

Re: which runlevel should I place my DB2 shutdown scripts?

Sorry I meant ...

===> Assuming K099 is the first shutdown/kill sequence number.
Yvonne Chan

Re: which runlevel should I place my DB2 shutdown scripts?

hi Micheal & S.K Chan,
Thanks for your reply, I will tried it out again.
James R. Ferguson
Acclaimed Contributor

Re: which runlevel should I place my DB2 shutdown scripts?

Hi Yvonne:

Although you already have an answer, let me provide a set of general details.

If you haven't, read either version of the document below. While the document dates to the 10.x release is remains wholly applicable in 11.x releases too. I???ll summarize the key points here.


The file /sbin/init.d/template is a good starting place for making your own start/stop scripts.

The /sbin/init.d directory contains all scripts used to startup and shutdown various subsystems.

Each script under /sbin/init.d should perform BOTH the startup and shutdown functions. In order to control the functionality within the script, each must also support standard arguments and exit codes. Scripts must be written for the POSIX shell. A template script may be found in /sbin/init.d/template.

There is no reason why the startup and shutdown script cannot start/kill multiple, but related processes. Remember to choose the appropriate rc.d directory -- one (1) is for core services; two (2) is for multiuser run-state; three (3) is for networked, multi-user; and four (4) is for graphical interfaces. Depending on the processes you are starting, or stopping, you want to make sure prerequisite services exist.

Each script in /sbin/init.d performs BOTH the startup and shutdown functions, and each will have two links pointing towards the script from /sbin/rc*.d: one for the start action and one for the stop action.

Start scripts begin with "S"; Kill (stop) scripts begin with "K". The order of execution for kill scripts is the reverse of the startup ones.

if a start script is placed in directory '/sbin/rc{X}.d' then its corresponding kill script is put in directory '/sbin/rc{X-1}.d'

A general rule-of-thumb is that the sequence number of the start script plus the sequence number of the kill script should add to 1000.

Subsystems should be killed in the opposite order they were started. This implies that kill scripts will generally not have the same numbers as their start script counterparts. If two subsystems must be started in a given order due to dependencies (e.g., S200sys1 followed by S300uses_sys1), the counterparts to these scripts must be numbered so that the subsystems are stopped in the opposite order in which they were started (e.g., K700uses_sys1 followed by K800sys1). The '1000' rule leads to this behavior.