- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- kill parent and its child process
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
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
тАО07-26-2007 10:41 PM
тАО07-26-2007 10:41 PM
kill parent and its child process
Thanks in advance,
Senthil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-26-2007 11:28 PM
тАО07-26-2007 11:28 PM
Re: kill parent and its child process
Also, you should be very leery of using kill -9.
One way to get the PIDs of a tree is to use:
$ UNIX95= ps -Hfu user
Then you can cut & paste a PID and PPID in one step. Move up 2 lines and cut 2 more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2007 12:13 AM
тАО07-27-2007 12:13 AM
Re: kill parent and its child process
You will either have to parse all the pids that have the same ppid (i.e. are children of the same parent).
e.g.
$ UNIX95= ps -C sshd -o pid= -o ppid=
990 1
13403 990
13405 13403
2671 2669
2669 990
Here 2669 and 13403 are both children of sshd pid 990.
An alternative, kill several birds with one stone, would be if they all belong to the same process group.
Then it is sufficient to only signal the pgid with a prepended minus sign.
e.g.
$ UNIX95= ps -g 2241 -o pid,ppid,pgid,comm
PID PPID PGID COMMAND
2244 2242 2241 oninit
2241 1 2241 oninit
2245 2242 2241 oninit
2242 2241 2241 oninit
2243 2242 2241 oninit
2246 2242 2241 oninit
2247 2242 2241 oninit
2248 2242 2241 oninit
2249 2242 2241 oninit
2250 2242 2241 oninit
Here we have several Informix processes that all belong to the same pgid 2241.
Then you could kill -s TERM -2241
(note you must specify the signal explicitly in that case or prepend -- to indicate that the following minus sign does not indicate an option)
However, one should never finish the database that way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2007 12:32 AM
тАО07-27-2007 12:32 AM
Re: kill parent and its child process
Process=$1
plist=$Process
ps -ef|grep $Process|grep -v grep
ps -ef|while read a b c rest
do
if [ "$c" = "$Process" ]
then
plist=$plist" "$b
fi
done
echo kill -9 $plist
If you like the output . Just use the command printed.
This is all good input but as indicated dangerous so dry run a few tests before making a command which just kills
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 08:25 PM
тАО07-29-2007 08:25 PM
Re: kill parent and its child process
I use the attached scripts killkids to kill all the childs of a process including a process itself (-s).
It run on hpux11i from years.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 08:26 PM
тАО07-29-2007 08:26 PM
Re: kill parent and its child process
this is the script (pidtree) used by the previous script.
Surely both can be improved. Please, in case someone improve them sent me a copy.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 09:54 PM
тАО07-29-2007 09:54 PM