- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Killing parent pid
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
тАО09-15-2009 05:46 AM
тАО09-15-2009 05:46 AM
user1 3870 1667 1 Sep 9 ? 4:52 b
user1 3871 1667 0 Sep 9 ? 4:50 c
user1 3878 1667 0 Sep 9 ? 4:49 d
user1 1667 1 0 Sep 9 ? 12:33 a
user1 3868 1667 0 Sep 9 ? 4:44 e
a is the parent process and b,c,d,e are the child processes.
Thanks,
Srini
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2009 05:53 AM
тАО09-15-2009 05:53 AM
SolutionIt all depends on the software and there is no definite answer as I know of.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2009 06:19 AM
тАО09-15-2009 06:19 AM
Re: Killing parent pid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2009 06:33 AM
тАО09-15-2009 06:33 AM
Re: Killing parent pid
PPID=whatever
ps -ef | awk {'print $3'} | grep $PPID
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2009 06:37 AM
тАО09-15-2009 06:37 AM
Re: Killing parent pid
PPID=whatever
ps -ef | grep $PPID
this output will also include a line for the parent process as well as all the child processes
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2009 07:14 PM
тАО09-15-2009 07:14 PM
Re: Killing parent pid
The ps command can show the entire hierarchy:
UNIX95=1 ps -eH
or
UNIX95=1 ps -efH
Be sure to copy/paste the entire line. UNIX95=1 sets a special option for ps.
But the best tool is pstree. Here's a link to it: http://en.wikipedia.org/wiki/Pstree
pstree -p #####
where ##### is any process in the tree. pstree will show the entire branch up and down.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2009 10:56 PM
тАО09-15-2009 10:56 PM
Re: Killing parent pid
In HP-UX 11.31 ptree exists and do the same as pstree.
Regards,
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2009 03:21 AM
тАО09-16-2009 03:21 AM
Re: Killing parent pid
A safer command would be:
PPID=whatever
UNIX_95=EXTENDED_PS ps -ef -opid= -ocomm= -oppid= | grep " $PPID$"
This makes sure you can search for PPID=1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2009 11:02 PM
тАО09-16-2009 11:02 PM
Re: Killing parent pid
Script starts here:
ppid=`ps -ef|grep 'TWM -u'|grep -v grep|awk '{print $2}'`
if [ -z "$ppid" ]
then
echo "no parent TM process running"
else
echo " Child processes are "
for child in `ps -ef|grep -w $ppid|grep -v grep|awk '{if($3!=1) {print $2}}'`
do
echo $child
#replace echo with kill
done
echo "Parent TM is " $ppid
fi
Thanks,
Srini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2009 11:41 AM
тАО09-17-2009 11:41 AM
Re: Killing parent pid
Always use ps to find processes by name, never grep. In your script, grep "TWM -u" may be unique but you can't depend on that. If you want to find all the TWM processes, use ps like this:
UNIX95=1 ps -C TWM -o pid= -o args=
This method ensures that grep will not find something else (like grep). Now if several copies of TWM are running and you want to select only the one with -u, then you can add grep to the result like this:
UNIX95=1 ps -C TWM -o pid= -o args= | grep -- -u
Be sure to use two dashes (grep --) to terminate the option processing and treat "-u" as a simple string.
But most important, do NOT grep for pid or ppid!!! This will find critical processes that happen to have matching numbers in the run string. ALWAYS use ps -p for exact PID matches.
Bill Hassell, sysadmin