- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script comment
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 04:23 PM
11-03-2005 04:23 PM
script comment
#!/usr/bin/sh
process='/app/oracle/product/9.2.0.2.0/bin/rman'
count='1'
limit='4'
PID=`ps -ef | grep "$process" | grep -v grep | grep -v ps | cut -c10-14 | sort -r`
function kill_rman
{
if [ -z "$PID" ];
then
echo "No process to kill"
else
echo kill -9 $PID
fi
}
while [ "$count" -lt "$limit" ]
do
echo "$count"
count=$(($count+1))
kill_rman
sleep 20
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 04:29 PM
11-03-2005 04:29 PM
Re: script comment
You have written to kill the process only not starting if it is killed already.
In this script,
#!/usr/bin/sh
process='/app/oracle/product/9.2.0.2.0/bin/rman'
count='1'
limit='4'
function kill_rman
{
# It should be here to keep on checking process ID dynamically.
PID="`ps -ef | grep "$process" | grep -v grep | grep -v ps | cut -c10-14 | sort -r`"
if [ -z "$PID" ];
then
echo "No process to kill"
else
echo kill -9 $PID
fi
}
while [ "$count" -lt "$limit" ]
do
echo "$count"
count=$(($count+1))
kill_rman
sleep 20
done
# end
exit 0
##########
If you want to have scripting guidance then feel free to give full requirement so that you will get PERFECT solution(s) ;)
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 07:22 PM
11-03-2005 07:22 PM
Re: script comment
instead of the long
ps -ef | grep "$process" | grep -v grep | grep -v ps | cut -c10-14 | sort -r
you might wish to
export UNIX95=XPG4
then
ps -ef -o pid,args | awk '$2=="'$process'" { print $1}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 08:02 PM
11-03-2005 08:02 PM
Re: script comment
I hope,
ps -ef -o pid,args | awk '$2=="'$process'" { print $1}'
will not work?
you have to export $process variable with awk as,
awk -v var=$process so that var can be used for if look.
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 08:09 PM
11-03-2005 08:09 PM
Re: script comment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2005 10:59 PM
11-03-2005 10:59 PM
Re: script comment
PLEASE do not kill processes beginning with 'kill-9'. This signal is not catchable and does not therefore offer a process any chance to remove its temporary files and/or shared memory segments!
This has been discussed many, many times in this Forum; perhaps the most recent here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=969402
Secondly, use the technique Jean-Yves has shown leveraging the UNIX95 (XPG4) behavior to EXACTLY select a process in question. The essential change I would make, however, is *not* to export the UNIX95 variable but rather set it *only* for the duration of the 'ps' command, thusly:
# UNIX95= ps -e -o ...
Note the space character after the "=" and before the 'ps'. This keeps the UNIX95 variable from applying to any commands *but* the one on the line on which it occurs.
The link above also shows another example of finding processes this way.
Regards!
...JRF...