- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: commands needed
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
05-23-2007 04:29 PM
05-23-2007 04:29 PM
appreciate if someone could provide the below command.
* grep a process id then kill the process, all command in one line. eg :
when i want to kill some processes with command oralcePROD , i have to : ps -ef |grep oraclePROD, from here i kill -9 PID, is there any command/script which i can run to kill all the oraclePROD process ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 05:38 PM
05-23-2007 05:38 PM
Re: commands needed
You could do the following:
# kill -9 $( UNIX95= ps -C oralcePROD -opid= )
(Make sure you test it with an "echo" before the kill.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 07:54 PM
05-23-2007 07:54 PM
Re: commands needed
i got error message on the command, pls advise.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 08:00 PM
05-23-2007 08:00 PM
Re: commands needed
you did simply typo:
oralcePROD instead of oraclePROD.
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 08:03 PM
05-23-2007 08:03 PM
Re: commands needed
before trying with 'kill', check, which process get reported by the 'ps' - in your case no output was produced, so kill got no process id(s):
Execute
UNIX95= ps -C oralcePROD -opid=
and check for spelling errors.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 08:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 08:21 PM
05-23-2007 08:21 PM
Re: commands needed
(It would be more helpful if you just cut n' paste the error rather that attach a bitmap.)
>HGH: you did simply typo:
Oops, I cut n' paste the line with the typo.
You could just redirect stderr so you don't get errors if there aren't any oraclePROD but you sure had a lot. :-)
# kill -9 $( UNIX95= ps -C oraclePROD -opid= ) 2> /dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 08:24 PM
05-23-2007 08:24 PM
Re: commands needed
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 08:47 PM
05-23-2007 08:47 PM
Re: commands needed
@Luk:
Since kill won't read its PIDs from stdin, something like
... | kill ..
won't work - you have to use
... | xargs kill ..
Nevertheless the POSIX part of 'ps' is much more reliable, IMHO.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 10:25 PM
05-23-2007 10:25 PM
Re: commands needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 10:33 PM
05-23-2007 10:33 PM
Re: commands needed
$ ps -ef |grep sam |awk -F "" '{print $2}'|kill â 9
Can not work because kill does NOT read from stdin!
you have to "xargs" the kill command this way:
$ ps -ef |grep sam |awk -F "" '{print $2}'|xargs kill â 9
see xargs(1)
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 10:34 PM
05-23-2007 10:34 PM
Re: commands needed
And if you want to see what the ps does, do the following to see why it doesn't kill all:
$ UNIX95= ps -C sam -opid=
From your hard to read bitmap, I see you have a samx (14569) and a shell script running /usr/sbin/sam (14564).
So you can replace sam by samx to get 14569. But you don't want to kill ALL sh's on the system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 11:33 PM
05-23-2007 11:33 PM
Re: commands needed
do
kill -9 $i
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 01:50 PM
05-24-2007 01:50 PM
Re: commands needed
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 03:56 PM
05-24-2007 03:56 PM
Re: commands needed
I can't see why that ps command is failing.
What does this show?
# UNIX95= ps -C oraclePROD
(I can't see your bitmaps accurately enough to tell what your other problems are. Can't you copy just text?
You seem to be echoing $UNIX95 in test.sh instead of echoing $(UNIX95= ps -C oraclePROD)
Note your ps -ef | grep oraclePROD, will find the grep and may kill it. You need to grep -v grep:
# kill -9 $(ps -ef | grep oraclePROD | grep -v grep | awk '{print $2}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 07:14 PM
05-24-2007 07:14 PM
Re: commands needed
The last line in your second bitmap, the one giving ">" :
you are just missing the closing ' before |xargs
Again please give the output of
# UNIX95= ps -C oraclePROD
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 09:22 PM
05-24-2007 09:22 PM
Re: commands needed
output for UNIX95= ps -C oraclePROD is :
tamcodb1:/# echo $(UNIX95= ps -C oraclePROD)
PID TTY TIME CMD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2007 09:31 PM
05-24-2007 09:31 PM
Re: commands needed
# echo $(UNIX95= ps -C oraclePROD)
PID TTY TIME CMD
Ok, this is saying there are no processes with the basename of oraclePROD. You could try changing it to just "oracle".
This probably occurs because Oracle is fiddling with argv[0] to make it pretty for the users and it no longer matches the real executable.
So it appears you'll need to use your grep solution:
# kill -9 $(ps -ef | grep oraclePROD | grep -v grep | awk '{print $2}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2007 11:18 PM
05-28-2007 11:18 PM
Re: commands needed
ps -ef|awk '/oraclePROD/{print $2}'|xargs -i kill -9 {}
ps -ef|awk '/oraclePROD/{ print "kill -9",$2 }'|sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 06:15 PM
05-29-2007 06:15 PM
Re: commands needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 07:11 PM
05-29-2007 07:11 PM
Re: commands needed
The proper way to do this is by assigning points. You have not assigned any points yet. Please read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
You can reopen it with:
http://forums1.itrc.hp.com/service/forums/helptips.do?#41