- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: kill a process by its name
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
тАО02-29-2008 03:58 AM
тАО02-29-2008 03:58 AM
kill a process by its name
I'm launching a java process through a script (to set classpath, environment vars, etc). This script receives as an argument the name of the class I want to execute.
I have severall processes being launched using this mechanism.
I'm trying to kill a child process (java) but when I use "ps -ex | grep java" the command line which gives me the classpath of all .jars used by this java child process is too short. I know the specific class that was used to launch that java process. However, when I do "ps -ex | grep java" I get similar lines for all running java processes because there are severall similar JARs in the classpath and the command line displayed is truncated in the ps. So I cannot clearly identify the PID of the process I want to kill.
Is there any way to kill a particular java process in this scenario? Or kill the child of the script used to launch it (the script is still in the ps as long as the process is running).
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 04:12 AM
тАО02-29-2008 04:12 AM
Re: kill a process by its name
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 04:14 AM - edited тАО07-30-2011 07:30 PM
тАО02-29-2008 04:14 AM - edited тАО07-30-2011 07:30 PM
Re: kill a process by its name
>I'm trying to kill a child process (java) but when I use "ps -ex | grep java" the
You don't want to use grep. Use -C:
$ UNIX95=EXTENDED_PS ps -xC java
>I get similar lines for all running java processes ... Or kill the child of the script used to launch it
Then you'll have to find it by the parent:
$ UNIX95=EXTENDED_PS ps -xC script
If you want to find all children:
$ UNIX95=EXTENDED_PS ps -ef -ocomm= -oppid= | fgrep $(UNIX95= ps -x -C script -opid=)
- Tags:
- EXTENDED_PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 04:27 AM
тАО02-29-2008 04:27 AM
Re: kill a process by its name
I can't use ps -xC java. I get the following error:
ps: illegal option -- C
usage: ps [-edaxzflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup] [-Z psetidlist]
Reading the "man ps" I can see I can only have -C or -o in XPG4 (which I assume I haven't available).
Any other ideas?
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 04:45 AM
тАО02-29-2008 04:45 AM
Re: kill a process by its name
He precedes the 'ps' command with 'UNIX95= '.
The 'UNIX95= ' (NOTE the space AFTER the = sign') turns on the XPG4 behavior for the command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 06:03 AM
тАО02-29-2008 06:03 AM
Re: kill a process by its name
$ UNIX95= ps -xC java
UNIX95=: Command not found.
I'm using tcsh and the TERM variable is set to xterm (can it have any influence?)...
- Tags:
- tcsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 07:54 AM
тАО02-29-2008 07:54 AM
Re: kill a process by its name
setenv UNIX95 1
ps -xC java
unsetenv UNIX95
hopefully you haven't changed "root"s default shell to tcsh. if you have, change it back to /sbin/sh immediately! Disaster lies down that path
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 10:45 PM
тАО02-29-2008 10:45 PM
Re: kill a process by its name
If you aren't use a real shell but the scummy csh or its derivatives, you need to mention that. (That's why I use a "$" prompt in my examples.)
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2008 12:50 AM
тАО03-03-2008 12:50 AM
Re: kill a process by its name
Doing a
$ setenv UNIX95 1
I could in fact use "ps -xC java" and all the command lines you told me to test. Thank you very much!
By the way, my root user is using the /sbin/sh and all other users have /usr/local/bin/tcsh.
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2008 02:18 AM
тАО03-03-2008 02:18 AM
Re: kill a process by its name
http://forums.itrc.hp.com/service/forums/helptips.do?#33