Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-17-2012, 02:13 PM
|
#1
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Rep:
|
Need error handling and output in the following job
#bin/sh
#source the environment
. /mnt/apps2/oracle/PATCH/apps/apps_st/appl/PATCH_hobsvbsdbt2.env
echo "YOU ARE SHUTTING DOWN THE PATCH APPLICATION SERVER " >> /mnt/backups/PATCH/coldbackup/shutdownapps.log
echo "check the logfile /mnt/apps2/oracle/PATCH/inst/apps/PATCH_hobsvbsdbt2/logs/appl/admin/log/adstpall.sh for more information..." >> /mnt/backups/PATCH/coldbackup/shutdownapps.log
# Shutdown the application
cd $ADMIN_SCRIPTS_HOME
UID_PWD=`cat /mnt/backups/PATCH/coldbackup/concsub_apps`
./adstpall.sh ${UID_PWD}
#USER=applPATCH
# sleep for 100 seconds
sleep 100
for process_list in `ps -ef|grep applpatch|grep -v tail|grep -v grep|grep -v bash|grep -v sshd|grep -v shutdown.sh|grep -v root|grep -v "ps -ef"|awk '{print $2}'`
do
kill -9 $process_list
done
echo "THE SHUTDOWN PROCESS FOR THE PATCH ENVIRONMENT IS COMPLETE " >> /mnt/backups/PATCH/coldbackup/shutdownapps.log
exit 0
|
|
|
07-17-2012, 03:00 PM
|
#2
|
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604
|
I'm not sure exactly what you need help here with, the script looks like it should run without issues as long as all of the variables can be satisfied properly.
Can you give us some more info into exactly what you are having issues with and what you are looking for?
|
|
|
07-17-2012, 03:22 PM
|
#3
|
Member
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261
Rep:
|
Greetings,
Well, I have done some clean-up below of your posted code, but I have a couple questions: - What shell is your /bin/sh linked to? You might want to call that directly instead of the /bin/sh link.
- I know we don't have all the variables that the script uses in the script itself since we are sourcing a .env file, but are you absolutely sure that when you cd into $ADMIN_SCRIPTS_HOME that it will be there and have the script you are about to call?
- There has *got* to be a cleaner way to get the process ids you need to kill. Do you know where the existing pid files for the application might be? Or, how about starting with:
- You are aware that the script says to find a logfile in a script file, right?
Code:
echo "check the logfile /mnt/apps2/oracle/PATCH/inst/apps/PATCH_hobsvbsdbt2/logs/appl/admin/log/adstpall.sh for more information..." >> /mnt/backups/PATCH/coldbackup/shutdownapps.log
Just making sure we're all on the same page here. So, here's my first blush:
Code:
#!/bin/sh
#
# Set our script env. Leaves us one place to change the location if we change it down the road.
LOGFILE="/mnt/backups/PATCH/coldbackup/shutdownapps.log"
#source the environment
. /mnt/apps2/oracle/PATCH/apps/apps_st/appl/PATCH_hobsvbsdbt2.env
echo "YOU ARE SHUTTING DOWN THE PATCH APPLICATION SERVER " | tee -a ${LOGFILE}
echo "Check the logfile for more information..." | tee -a ${LOGFILE}
# Still curious about the following line...
echo "Logfile can be found at /mnt/apps2/oracle/PATCH/inst/apps/PATCH_hobsvbsdbt2/logs/appl/admin/log/adstpall.sh" | tee -a ${LOGFILE}
# Shutdown the application
cd $ADMIN_SCRIPTS_HOME
UID_PWD=`cat /mnt/backups/PATCH/coldbackup/concsub_apps`
./adstpall.sh ${UID_PWD} && echo "Shutdown underway... Cleaning up remaining processes." | tee -a ${LOGFILE}
#USER=applPATCH
# sleep for 100 seconds
sleep 100
for process_list in `ps -ef|grep applpatch|grep -v tail|grep -v grep|grep -v bash|grep -v sshd|grep -v shutdown.sh|grep -v root|grep -v "ps -ef"|awk '{print $2}'`
do
kill -9 $process_list
done
echo "THE SHUTDOWN PROCESS FOR THE PATCH ENVIRONMENT IS COMPLETE " | tee -a ${LOGFILE}
exit 0
#
## EOF
HTH. Let us know.
Last edited by ShadowCat8; 07-17-2012 at 03:26 PM.
Reason: Option for cutting down the greps
|
|
|
All times are GMT -5. The time now is 08:21 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|