- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: kill a process by name
Operating System - HP-UX
1752277
Members
4604
Online
108786
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-23-1999 04:16 AM
тАО11-23-1999 04:16 AM
kill a process by name
I would like to be able to kill processes running on HP-UX 10.2.x by
specifiying the name of the process. I did this on earlier versions of HP-UX
by grep'ing the 'ps -ef' listing, stripping out the grep command, cutting the
PID from the resulting line, then issuing a kill on that PID. I did a ?wc ?l?
of the lines, and would kill if at least 1 result was found. This does not
seem to work as well as it used to. The $Count does not always "see" the
process, even though it *is* running. Is there a better way to do this?
Thanks.
specifiying the name of the process. I did this on earlier versions of HP-UX
by grep'ing the 'ps -ef' listing, stripping out the grep command, cutting the
PID from the resulting line, then issuing a kill on that PID. I did a ?wc ?l?
of the lines, and would kill if at least 1 result was found. This does not
seem to work as well as it used to. The $Count does not always "see" the
process, even though it *is* running. Is there a better way to do this?
Thanks.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-1999 05:05 AM
тАО11-23-1999 05:05 AM
Re: kill a process by name
Here's a script called killem that does what you're looking for:
#!/bin/sh
ps -ef|grep $1|grep -v grep|grep -v killem|
while read X; do
PID=`echo $X|awk '{print $2}'`
kill $PID
done
The script takes one command line arg: the name of the process to look for, and
kills ALL instances it finds.
If you change the name of the script, also change the name on the grep line of
the script. The pipe at the end of that line is not a typo.
Be careful to specify enough of the name to avoid conflicts. You probably don't
want to do things like "killem sh," which would kill all user shells and
anything else that matches "sh".
MrNeil
#!/bin/sh
ps -ef|grep $1|grep -v grep|grep -v killem|
while read X; do
PID=`echo $X|awk '{print $2}'`
kill $PID
done
The script takes one command line arg: the name of the process to look for, and
kills ALL instances it finds.
If you change the name of the script, also change the name on the grep line of
the script. The pipe at the end of that line is not a typo.
Be careful to specify enough of the name to avoid conflicts. You probably don't
want to do things like "killem sh," which would kill all user shells and
anything else that matches "sh".
MrNeil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-1999 07:01 AM
тАО11-23-1999 07:01 AM
Re: kill a process by name
Hi Bill,
I have attached one of the first scripts I've ever wrote to kill processes. It
will do a search for the process given as a parameter to the script and ask you
which one to kill if more than one process matches the search. Please, PLEASE
don't mind the dirty style :-)
Paul "Jeez this script could destroy my reputation" Heffels
PS Never mind the Dutch comments
I have attached one of the first scripts I've ever wrote to kill processes. It
will do a search for the process given as a parameter to the script and ask you
which one to kill if more than one process matches the search. Please, PLEASE
don't mind the dirty style :-)
Paul "Jeez this script could destroy my reputation" Heffels
PS Never mind the Dutch comments
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP