The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to print parent process name mahendramahendr Shell Programming and Scripting 3 05-23-2008 07:59 AM
Who is the parent of a killed process ? Puntino UNIX for Dummies Questions & Answers 6 05-13-2008 04:50 AM
Can a child process return a specific value to a parent process ? Ametis1970 High Level Programming 8 04-09-2008 11:22 PM
how to find the chid process id from given parent process id guhas Shell Programming and Scripting 3 10-13-2005 08:13 AM
what the getppid of parent process print ramneek IP Networking 1 08-24-2005 09:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-03-2002
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
Question identify parent process in ps?

I need to write a script to monitor user processes that revert to parent process id = 1
I can do this with a grep " 1 " or awk and evaluation.
but
Is there a switch on the ps command or another command to specify parent id on proccesses?
I tried ps with the -p ppid=nnnnn but it doesnt seem to work.

thanks
  #2 (permalink)  
Old 07-03-2002
janr janr is offline
Registered User
  
 

Join Date: Jun 2002
Location: Amsterdam (Netherlands)
Posts: 142
On the most unix flavours the -f(ull) option will show the PPID

like
/logs: ps -f
UID PID PPID C STIME TTY TIME CMD
net400 24032 24268 2 17:02:15 pts/0 0:00 ps -f
net400 24268 13026 0 16:37:04 pts/0 0:00 -csh
/logs:
  #3 (permalink)  
Old 07-03-2002
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
Yes. but I want to monitor processes that have PPID = 1
I want to know if there is a switch to identify PPID specific

For example: ps -ef -p 29538 will give me process id 29538
I dont see a switch in the man pages for ppid
  #4 (permalink)  
Old 07-03-2002
sskb
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Hi
I think the following thread addresses similar issue.

finding process id

Good Luck!
sskb
  #5 (permalink)  
Old 07-03-2002
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
No. thats a lot of info. but doesnt give me an answer.
I am looking for an alternative to this:


for PID in `ps -ef |grep -v root| grep " 1 " | awk '{print $2}'`


The grep " 1" is giving me all processes running under PPID = 1.

I could also awk'{print $3}' and evaluate it for a value of 1

I found in the man pages a switch -p to identify proccesses for a PID.
I am wondering if maybe there is a switch for PPID that I'm missing when I look up the use of ps.
  #6 (permalink)  
Old 07-03-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
For a list of pid's that are not owned by root but have a ppid of 1, I would go with:
Code:
#! /usr/bin/ksh
ps -ef | sed 1d | while read user pid ppid junk ; do
      if [[ $user != root && $ppid = 1 ]] ; then
            echo $pid
      fi
done
exit 0
  #7 (permalink)  
Old 07-03-2002
MizzGail's Avatar
MizzGail MizzGail is offline
Registered User
  
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 164
This works great. Thanks !
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0