- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell script that finds a process by name, the...
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
Discussions
Discussions
Forums
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
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
тАО03-15-2009 10:58 AM
тАО03-15-2009 10:58 AM
Re: Shell script that finds a process by name, then kills
I suspect that pgrep / pkill will have the same issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2009 11:52 AM
тАО03-15-2009 11:52 AM
Re: Shell script that finds a process by name, then kills
That doesn't matter, you should always use UNIX95=EXTENDED_PS with ps(1). ;-)
My alias does that.
And if we really wanted to be picky, that should be fgrep or "GLB\.JOB".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2009 12:29 PM
тАО03-15-2009 12:29 PM
Re: Shell script that finds a process by name, then kills
> OldSchool: the UNIX95 switch won't work in this case
I disagree if the process name is also known. If it isn't then I would agree.
Using the UNIX95 mode of 'ps' _will_ help _isolate_ the process by name. Then, a simple 'awk' can filter the match a bit more and issue the 'kill'.
> Dennis: you should always use UNIX95=EXTENDED_PS with ps(1). ;-)
Well, that's your preference and I will agree that it does eliminate ambiguity for many, but that is _not_ strictly necessary. Wriing "UNIX95= " with trailing whitespace is sufficient to set/define the environment. ;-)
So, in all, one might meld several thoughts together into something like:
# UNIX95= ps -C jsh -o pid= -o args=|awk '/GBL\.JOB.+/ {system("kill " $1)}'
...which looks for processes named 'jsh' with command arguments that contain "GBL.JOB*" [ which we might be able to anchor to the end of the string ] and then kills them. The "=" sign after the 'pid' and 'args' options suppresses the heading line so we don't have to deal with it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2009 12:53 PM
тАО03-15-2009 12:53 PM
Re: Shell script that finds a process by name, then kills
That's not my point. My point to OldSchool was that you should use UNIX95 with ps, even if it "won't work in this case".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-15-2009 01:17 PM
тАО03-15-2009 01:17 PM
Re: Shell script that finds a process by name, then kills
> Dennis: >JRF: that's your preference
That's not my point. My point to OldSchool was that you should use UNIX95 with ps, even if it "won't work in this case".
And I _absolutely_ agree. At the least, one can match a process name without undo fuss [ as for instance, when using 'grep
Interestingly, 'pgrep()' and 'pkill()' available in 11.31 avoid matching themselves.
With warm Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2009 04:53 AM
тАО03-16-2009 04:53 AM
Re: Shell script that finds a process by name, then kills
the point I was trying to make is that since the process is jsh, he can't use "GLB.JOB" for the process field, and for the same reason pkill probably won't succeed either....he'd have to look for the jsh process and then do additional filtering.
I should have been more clear....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-18-2009 08:02 AM
тАО03-18-2009 08:02 AM
Re: Shell script that finds a process by name, then kills
kill -9 `awk '{print $2}' temp.1`
rm temp.1
where $1 = GLB.JOB*
- « Previous
-
- 1
- 2
- Next »