The UNIX and Linux Forums  

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 04:59 AM
Who is the parent of a killed process ? Puntino UNIX for Dummies Questions & Answers 6 05-13-2008 01:50 AM
Can a child process return a specific value to a parent process ? Ametis1970 High Level Programming 8 04-09-2008 08:22 PM
how to find the chid process id from given parent process id guhas Shell Programming and Scripting 3 10-13-2005 05:13 AM
what the getppid of parent process print ramneek IP Networking 1 08-24-2005 06:52 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2002
MizzGail's Avatar
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 156
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Forum Sponsor
  #2 (permalink)  
Old 07-03-2002
Registered User
 

Join Date: Jun 2002
Location: Amsterdam (Netherlands)
Posts: 142
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 156
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Hi
I think the following thread addresses similar issue.

finding process id

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

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 156
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,253
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Registered User
 

Join Date: Sep 2001
Location: Syracuse, NY
Posts: 156
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
This works great. Thanks !
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
421 service not available, remote server has closed connection ^m autosys awk trim bash eval bash exec bash for loop command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix daemon process export command in unix find grep find mtime find null character in a unix file grep multiple lines grep or grep recursive hp-ux ifconfig inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude tar extract to folder test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix simulator unix.com vi select all vi substitute vi+substitute+end+of+line+character while loop within while loop shell script


All times are GMT -7. The time now is 05:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101