LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 07-17-2012, 02:13 PM   #1
wdsmith45
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
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
 
Old 07-17-2012, 03:00 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
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?
 
Old 07-17-2012, 03:22 PM   #3
ShadowCat8
Member
 
Registered: Nov 2004
Location: Arcadia, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 220

Rep: Reputation: 46
Greetings,

Well, I have done some clean-up below of your posted code, but I have a couple questions:
  1. What shell is your /bin/sh linked to? You might want to call that directly instead of the /bin/sh link.
  2. 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?
  3. 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:
    Code:
     ps -U applpatch ef
  4. 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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh -t output to a file for handling garyrickert Linux - Server 10 02-10-2012 11:46 PM
problem in handling pipes concept while passing error and output in two files nagendrar Programming 1 11-06-2009 09:11 AM
examples with 2 pipes+fork+handling error,output in different files nagendrar Programming 4 11-06-2009 07:36 AM
how to implement suspended job handling of a shell using c chrislam Programming 1 09-19-2007 12:43 PM


All times are GMT -5. The time now is 10:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration