- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ps command question
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
04-09-2003 06:37 AM
04-09-2003 06:37 AM
ps command question
ps -C happy
This doesn't seem to work on HP-UX 11.11. Does any one know how I could obtain the process id of the program (which I need to feed to a kill -9 command to shut down each instance of the "happy" program.
Thank you!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:39 AM
04-09-2003 06:39 AM
Re: ps command question
should do it.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:44 AM
04-09-2003 06:44 AM
Re: ps command question
Try this..
UNIX95= ps -C happy
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:46 AM
04-09-2003 06:46 AM
Re: ps command question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:49 AM
04-09-2003 06:49 AM
Re: ps command question
I'm familiar with the ps -ef | grep happy but the only thing I need is the actual PID of happy (not the rest of the stuff) and I then want to pass the PID's of any occurence to happy to:
kill -9 PID1 PID2 PID3, etc.,etc,e tc.
(all within a script). Manually doing this is no problem....but I'd really like to pass the PID and only the PID's of happy to kill -9.
Thanks for the prompt responses!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:49 AM
04-09-2003 06:49 AM
Re: ps command question
Hello,
Try this script.
Olav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:57 AM
04-09-2003 06:57 AM
Re: ps command question
for i in `ps -ef | grep happy | grep -v grep | awk '{print $2}'`
do
kill -9 $i
done
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 06:59 AM
04-09-2003 06:59 AM
Re: ps command question
Then this should do it:
ps -ef | grep ' '$USERNAME' ' | grep -v "resetuser" | awk '{ print $1,$2 }'
> /tmp/reset.tmp
PROCESSES=`grep $USERNAME /tmp/reset.tmp | awk '{ print $2 }' | sort -n`
for PROC in $PROCESSES
do
echo "\tKilling process $PROC"
kill $PROC
done
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 07:02 AM
04-09-2003 07:02 AM
Re: ps command question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 07:02 AM
04-09-2003 07:02 AM
Re: ps command question
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 07:06 AM
04-09-2003 07:06 AM
Re: ps command question
You merely forgot to set the XPG4 (UNIX95) option. For exmaple, to find the 'pid' of the 'syncer' daemon, di:
# UNIX95= ps -C syncer|awk 'NR>1 {print $1}'
Note that a space follows the UNIX95= and there is no semicolon before the 'ps'. That set's UNIX95 only for the command line.
In the avove, I skip the header returned from 'ps' and grab the pid (column-1) for the "syncer" daemon.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 07:14 AM
04-09-2003 07:14 AM
Re: ps command question
Beware using a simple 'grep' to find the process you truly want! You will return lines that match "happy" when "happy" is a command (basename) *and* when "happy" happens to be an argument to some other command!
Therein lies the value of using XPG4 (UNIX95) extentions.
Regards!
...JRF...