identify parent process in ps?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers identify parent process in ps?
# 1  
Old 07-03-2002
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  
Old 07-03-2002
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  
Old 07-03-2002
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  
Old 07-03-2002
Hi
I think the following thread addresses similar issue.

https://www.unix.com/unix-for-dummies-questions-and-answers/5529-finding-process-id.html?s=

Good Luck!
sskb
sskb
# 5  
Old 07-03-2002
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  
Old 07-03-2002
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  
Old 07-03-2002
This works great. Thanks !
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Find parent process (not process ID)

Hi: I have a program written in FORTRAN running on AIX platform. It is because missing of documentation and without root password, therefore we want to modify the program so that we can find out which script/program that call this FORTRAN program. I have google for few days, all of them are... (3 Replies)
Discussion started by: cstsang
3 Replies

2. Shell Programming and Scripting

parent process needs to wait

I have two scripts lets say A.expect and B.sh needs to be executed. I am executing B.sh from A.expect where B.sh has sleep command. My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits. but my A.expect should execute only after completing B.sh. Is... (3 Replies)
Discussion started by: priya@2012
3 Replies

3. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

4. Emergency UNIX and Linux Support

signal between parent process and child process

Hello, everyone. Here's a program: pid_t pid = fork(); if (0 == pid) // child process { execvp ...; } I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process. However I don't want to child process to receive the... (7 Replies)
Discussion started by: jackliang
7 Replies

5. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

6. Shell Programming and Scripting

How to make the parent process to wait for the child process

Hi All, I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program. I want 1st script to wait until the 'C' program completes. I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies

7. UNIX for Dummies Questions & Answers

To identify process

i want a command to display all the process running for partical user and in all process i want to see only particular process details.. pls suggest comand like ps -ef (1 Reply)
Discussion started by: Babu154
1 Replies

8. UNIX for Dummies Questions & Answers

parent process

I need to kill all the processes of user "release" on system "PROterm" or the parent process for the user I did this ps -ef | grep PROterm | grep release i got release 2900014 2961494 0 12:19:44 pts/3 0:00 PROterm release 3264694 2900014 0 12:19:44 - 0:00 PROterm if i... (7 Replies)
Discussion started by: ajit.yadav83
7 Replies

9. UNIX for Advanced & Expert Users

How can i get the parent process only?

Hello, I'm running one script every night and that's kick off through cron jobs. Inside the script i'm checking whether my script is already running or not. I'm using following command to check whether is running or not. ps -eaf | grep "test_PID.ksh" | grep -v "grep test_PID.ksh"... (5 Replies)
Discussion started by: nirav_soni
5 Replies

10. Shell Programming and Scripting

how to find the chid process id from given parent process id

how to find the chid process id from given parent process id.... (the chid process doesnot have sub processes inturn) (3 Replies)
Discussion started by: guhas
3 Replies
Login or Register to Ask a Question