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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help to schedule weekly AIX reboot 1

Status
Not open for further replies.

MCubitt

Programmer
Mar 14, 2002
1,081
GB
We're running an AIX 5.1 server with Oracle 9.2.0.1.0 running on it and several databases.

The AIX appears to log itself out of our network every now and again (Mondays, so far) - could be a timeout variable?

Anyway, I have been asked to restart the AIX server weekly since that is also what we do with our existing IBM AS/400 machine.

I need to know how to correctly shut down databases, listeners and the server so that it reboots and logs in automatically as if nothign ever happened!

My knowledge of Unix is very limited (attended a Hands on Intro to Unix).

Thanks
 
As you can see by these examples I am running 8 & 9 on the same server - adjust as required.

In the /etc directory create a file called rc.oracle. This is the startup file for Oracle and should contain the following;

#!/bin/ksh
su - oracle9 -c /u02/oracle9/oracle9/bin/dbstart # Start all local Databases
su - oracle9 -c /u02/oracle9/oracle9/bin/lsnrctl listener9 start # Start the Oracle 9 Listener
su - oracle -c /u05/app/oracle/product/8.0.5/bin/lsnrctl listener start # Start the Oracle 8 Listener

If you are using Intelligent Agent and Apache add extra lines to start them up

Create a file called rc.shutdown to include the following;

su - oracle -c /u05/app/oracle/product/8.0.5/bin/lsnrctl stop
su - oracle9 -c /u02/oracle9/oracle9/bin/lsnrctl listener9 stop # Stop the Oracle 9 Listener
su - oracle -c /u02/oracle9/oracle9/bin/dbshut


Extra lines for Intelligent agent and Apache as above


The files should be owned by root, group system and be executable

When you reboot the system DO NOT use the 'F' flag as this bypasses all shutdown scripts and just terminates all processes (not too good for your database!)

Alex
 
Thanks for the script. That is a starting point.

However, I still do not know how to schedule a job on UNIX so it reboots at, say, 1am every Sunday.

ANy ideas?


 
Cron is your friend :
crontab -e puts you into a VI session to edit the crontab
Insert a line like :
00 1 * * 0 /yourscriptdir/yourshutdown.scr

Dickie Bird (:)-)))
 
Although dickiebird is correct in his answer, perhaps you would be more comfortable doing the following.

As root
crontab -l > temp
edit temp using vi
when you are satisfied it is correct then do
crontab temp
crontab -l will show you the current crontab

Alex
 
Thanks to both of you. Excuse my ignorance, but I still do not understand how I set it to run on every SUNDAY at 1am. Is 00=Sunday and 1 = 1am?

Thanks again.
 
The 00 is on the hour
The 1 is the hour
The first * is the day of the month (1-31)
The second * is the month of the year (1-12)
The 0 is for sunday (weekdays are 0-6 starting on sunday)

So that's

00 1 * * 0 /yourscriptdir/yourshutdown.scr

for 01:00 every Sunday

Alex

 
Checkout 'man crontab' for a detailed explanation

Alex
 
Thanks guys. You have really helped. Just to put my mind at rest, can I confirm this is correct?

To automatically start the databases and listener upon a restart, I have created a file in /etc named rc.oracle. This contains:

#!/bin/ksh
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/dbstart
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/lsnrctl start


I also created a shutdown script in /etc named rc.shutdown. This contains:

su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/lsnrctl stop
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/dbshut


Granted permissions thus:
chgrp system rc.shutdown
chgrp system rc.oracle
chmod 754 rc.shutdown
chmod 754 rc.oracle


Once I have confirmed the scripts work when run manually, I will add a weekly reboot. This will be done using (as root):
crontab -l > temp
vi temp
I will add the line 00 1 * * 0 /etc/rc.shutdown and then write/quit vi
crontab temp
and use crontab - l to check it.
 
ADDENDUM!

After the line:
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/dbshut

Should I add:
reboot


I am hoping that this will reboot and automatically log back in. Is this the case?
 
No - the shutdown command should be in a seperate file

The other files will be executsed automagically by AIX

The shutdown file need to contaon 'shutdown -r'

Alex
 
See? I told you I was new to this lark!

Many thanks once again.
 
Just read the post again

The file in crontab to be executed is not rc.shutdown

It is a file which is created by you somewhere

e.g. /home/user/reboot_the_machine

this contains the 'shutdown -r' command

Alex
 
Yes, thanks. I have now amended my document:

To automatically start the databases and listener upon a restart, I have created a file in /etc named rc.oracle. This contains:

#!/bin/ksh
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/dbstart
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/lsnrctl start


I also created a shutdown script in /etc named rc.shutdown. This contains:

su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/lsnrctl stop
su - oracle -c /oracle/app/oracle/product/9.2.0.1.0/bin/dbshut


and the actual scheduled shutdown job in /etc named shutdown.scr. This contains:

shutdown -r


Granted permissions thus:
chgrp system rc.shutdown
chgrp system rc.oracle
chgrp system shutdown.scr
chmod 754 rc.shutdown
chmod 754 rc.oracle
chmod 754 shutdown.scr


Once I have confirmed the scripts work when run manually, I will add a weekly reboot. This will be done using (as root):
crontab -l > temp
vi temp
I will add the line 00 1 * * 0 /etc/shutdown.scr and then write/quit vi
crontab temp
and use crontab - l to check it.
 
I think you need to do one more thing: Add the running of the rc.oracle to your inittab so the databases start when the system comes up. Add this to /etc/inittab:

oracle:2:wait:/etc/rc.oracle > /dev/null 2&1

You also could add the script to one of the /etc/rc.d directories (assuming the /etc/rc.d/<dirctory> is in the inittab).
 
Oops. Typo. Sorry about that.

The line for /etc/inittab should be:

oracle:2:wait:/etc/rc.oracle > /dev/null 2>&1

And to further explain my last paragraph: You could add the script to the /etc/rc.d directory, but if you have the line as above in inittab, you don't need to.
 
bi - well spotted - forgot that bit (well you don't do this stuff roo often do you :) )

Alex
 
Thanks again for help. I have just tested it because yet again, our server lost connection with the network but moreso , I am unable to even start a terminal session from the server directly!

A few queries:

1. Attempting the Exit > Continue Logout caused a system hang (grey background with cross and no movemnet at all). This could have been a separate issue.

2. Once the system did come back (flicked the switch) I made the amendment to the inittab file. Then performed a manual shutdown -r. Soon after the screen requested a login. How do I avodi this since overnight no one will be at teh screen!

3. Again, once the system came back I had to login but I presume the system is still available and ready, just not access to teh screen - right?

Anyway, the databases were there and I was able to connect. So thank you!






 
2. the system console will always prompt for a login when the system is rebooted - it doesn't me you have to log in though :)

3. After the login prompt appears on the console the system is generally available for login, BUT your database(s) may not have started up (depending on their size and quantity)

Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top