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

mail from shutdown/startup script problem 1

Status
Not open for further replies.

dandan123

Technical User
Sep 9, 2005
505
0
0
US
One of our dba's is trying to send out an e-mail whenever the system shuts down or starts up using the database stop/start scripts.

They have the scripts in /etc/rc2.d

When I run the scripts manually using the start/stop switch everything works fine, the database starts/stops and an e-mail gets sent out.

However when I do an init 6 I get no e-mail.

Where do you think the problem could be ?
 
* Any pathing/environment variable issues?
* Have you tried to run the commands with the full path names? * Are the scripts in the correct format (S##script, K##script, readable, executable, etc.)?
 
Is mail shutdown before the database?

I want to be good, is that not enough?
 
If the rest of the script works well, and it's only the mail that's not working, I'd suspect environment as spamly said, so I'd try to put the full path.
If it still doesn't work post here the mail part of the script.
 
Here's the script, after adding the path to mailx I'm getting mail when the system starts up but not when it shuts down.

The shutdown script runs from rc2.d while sendmail is getting killed in rc1.d

case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login will not prompt the
# user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart > $TMPFILE
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start ORA_LISTENER" >>$TMPFILE
/usr/bin/mailx -s "server rebooted - db startup" xxx.xxxx@xxx.com < $TMPFILE
/usr/bin/mailx -s "NOTIFICATION TO DATACENTER" xxx.xxxx@xxx.com < $EXCFILE2
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login will not prompt the
# user for any values
/usr/bin/mailx -s "NOTIFICATION TO DATACENTER " xxx.xxxx@xxx.com < $EXCFILE1
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop ORA_LISTENER" > $TMPFILE
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut >>$TMPFILE
/usr/bin/mailx -s "server rebooted - db shutdown" xxx.xxxx@xxx.com < $TMPFILE
;;
 
Try linking to your script in /etc/rc0.d as K##script.
All shutting run levels (0, 5 and 6) process the scripts in rc0.d
 
MoreFeo that partially solved the problem , thanks !

In the stop section the e-mail before oracle shutsdown goes out but the e-mail after oracle shutsdown doesn't go out.

Not a big deal and thanks again for your help.
 
One of the su - is not finishing or returning in a proper way (I guess). Take a look at TMPFILE to see if it's stopping the listener and the db properly.
 
Forgot that you've already said that executing the script manually everything goes ok.
In this case perhaps it is that it takes too long to shutdown the listener and the db, so when it finishes sendmail is already stopped (sendmail is also stopped in rc0.d, there's a K##sendmail).
 
I see a sendmail stop script in rc1.d also, why is it in two places ?

Also the db shutdown script in rc0.d is K10 while sendmail is K36, so wouldn't the db shutdown script complete before the sendmail shutdown starts ?
 
Run level 0 is to put the system at the init state ok>. Used to shutdown the system.
Run level 1 is a single user mode. Root is the only user on the system, and only basic kernel functions are enabled. A limited number of filesystems (usually only root and /usr) are mounted. Used for maintenance and troubleshooting.

So in run level 1 it also needs to shutdown almost everything.

The other thing, I don't know if it waits the end of a script before running the others.
 
You can try to modify the K36sendmail, and change it to _K36sendmail.
This way it won't execute de stop script, and sendmail will be killed a little bit later. If doing this everything works ok, this means that it's executing the K36sendmail before finishing the db shutdown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top