- 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-12-2009 08:04 AM
тАО03-12-2009 08:04 AM
I need to create a cron that will do the following:
# ps -ef | grep GLB.JOB*
bnk 15855 1 0 Mar 10 ? 0:20 jsh -Jb -c EX EB.PHANTOM.PH MIA.
OFS.USER GLB.JOBBL
root 3208 23349 0 12:10:09 pts/tp 0:00 grep GLB.JOB*
#
Then to kill the PID in this case its 15855
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 08:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 08:13 AM
тАО03-12-2009 08:13 AM
Re: Shell script that finds a process by name, then kills
ps grep kill
would find many examples, including some
cautions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 08:22 AM
тАО03-12-2009 08:22 AM
Re: Shell script that finds a process by name, then kills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:15 AM
тАО03-12-2009 09:15 AM
Re: Shell script that finds a process by name, then kills
If you are running 11.31, look at 'pkill'.
If you are not running 11.31, make sure you match the process _exactly_ by name:
# kill $(UNIX95= ps -C GLBJOB -o pid=)
...note that there is _whitespace_ following 'UNIX95=' so that this mode is armed _only_ for the duration of the command line.
Regards!
...JRF...
- Tags:
- UNIX95
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:27 AM
тАО03-12-2009 10:27 AM
Re: Shell script that finds a process by name, then kills
This won't work because GLB.JOB is a parm, not the name (jsh).
>note that there is _whitespace_ following 'UNIX95=
Instead of explaining this each time, I use:
UNIX95=EXTENDED_PS ps ...
- Tags:
- EXTENDED_PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:41 AM
тАО03-12-2009 10:41 AM
Re: Shell script that finds a process by name, then kills
> Dennis: This won't work because GLB.JOB is a parm, not the name (jsh).
Ah, yes, so this should read:
# kill $(UNIX95= ps -C jsh -o pid=)
...since the request is to "...finds a process by name, then kills...:
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 06:57 PM
тАО03-12-2009 06:57 PM
Re: Shell script that finds a process by name, then kills
But I have to admi that I do still too often search through ps -ef output.
If I do, then I prefer to have awk do all the work. I like to test with an echo statement first, then go for the kill:
$ ps -ef | awk '/GLB.JOB/ {system( "echo -9 " $2)}'
$ ps -ef | awk '/GLB.JOB/ {system( "kill -9 " $2)}'
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:23 PM
тАО03-12-2009 09:23 PM
Re: Shell script that finds a process by name, then kills
> first, [...]
I'd be very reluctant to automate a job like
this fully, and then schedule it to run
periodically. I have an old, lame (ps+grep)
script ("/misc/kil") which displays the "ps"
line, and then asks the user for confirmation
before whacking anyone.
There are some good reasons to save a process
ID in a file somewhere when starting a job,
and then (after a quick validity check)
whacking that PID instead of trying to divine
the right PID later. Call me a coward.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 11:04 PM
тАО03-12-2009 11:04 PM