# Shutdown scripts

**URL:** <https://community.unix.com/t/shutdown-scripts/153309>\
**Category:** SuSE\
**Created:** [May 11, 2005, 3:03pm UTC](https://community.unix.com/t/shutdown-scripts/153309 "2005-05-11T15:03:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luft](https://community.unix.com/letter_avatar/luft/32/5_5575768a8748004e209b776fc1b2916d.png) [@luft](https://community.unix.com/u/luft)\
**Post date:** [May 11, 2005, 3:03pm UTC](https://community.unix.com/t/shutdown-scripts/153309/1 "2005-05-11T15:03:31Z")

</div>

Hello all

I'm trying to automate the startup/shutdown of my database whenever the OS is bounced ...

OS : Linux (Kernel : 2.4.20.-6)  
Oracle : 9.2.0.5

The contents of /etc/init.d/dbora file is listed below

case "$1" in

'start')  
su - $ORACLE\_OWNER -c "$ORACLE\_HOME/bin/dbstart"  
su - $ORACLE\_OWNER -c "lsnrctl start LISTENER"  
su - $ORACLE\_OWNER -c "agentctl start"  
;;  
'stop')  
su - $ORACLE\_OWNER -c "agentctl stop"  
su - $ORACLE\_OWNER -c "lsnrctl stop LISTENER"  
su - $ORACLE\_OWNER -c "$ORACLE\_HOME/bin/dbshut"  
;;  
\*)  
echo $"Usage: $prog {start|stop}"  
exit 1  
esac  
exit

Contents of /etc/oratab is  
ORA920:/u01/app/oracle/product/9.2.0:Y

I created all the required links

ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora  
ln -s /etc/init.d/dbora /etc/rc4.d/S99dbora  
ln -s /etc/init.d/dbora /etc/rc5.d/S99dbora  
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora  
ln -s /etc/init.d/dbora /etc/rc6.d/K10dbora

I shutdown the Linux system using both init 6 and init 0 and in both cases the automation process started up the oracle instance but it did not shut the oracle instance down before shutting down Linux system.My S\* scripts are working fine but not my K\* scripts. Am I missing something here ?

PS:  
There are 2 files in /etc/rc0.d and /etc/rc6.d ,

S00killall -\> ../init.d/killall\*  
S01reboot -\> ../init.d/halt\*

Why are these S\* scripts in rc0 and rc6 directories ...Seems to me like these S\* scripts are getting executed before the K\* scripts in in /etc/rc0.d and /etc/rc6.d ...but I'm not sure what is really going on here ...

Thanks

---

<div class="post-metadata">

**Author:** ![zazzybob](https://community.unix.com/user_avatar/community.unix.com/zazzybob/32/112_2.png) [@zazzybob](https://community.unix.com/u/zazzybob)\
**Post date:** [May 15, 2005, 6:17am UTC](https://community.unix.com/t/shutdown-scripts/153309/2 "2005-05-15T06:17:02Z")

</div>

Some flavours of Linux have their own ideas about Startup and Shutdown scripts.

For example - on SuSE Linux, changing runlevel from, say, runlevel 5 to runlevel 0 involves executing the K\* scripts in the runlevel 5 directory before it leaves runlevel 5 for runlevel 0, which is different to traditional \*nix.... So what you'll need to do is execute

```nohighlight
ln -s /etc/init.d/dbora /etc/rc3.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc4.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc5.d/K10dbora

```

and that should fix it..

Think about it like this (for SuSE Linux, anyways ;)) - on entering runlevel X, the S\* scripts in rcX.d are excuted. On leaving runlevel X, the K\* scripts in rcX.d are executed.

Cheers  
ZB
