find the Root ID from the processes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find the Root ID from the processes
# 1  
Old 01-11-2009
find the Root ID from the processes

Hi Friends,

The problem has a simple solution but i am not able to do that, need your help

dmadmin 9558 9511 0 Jan 02 ? 0:00 ./documentum -docbase_name secm1 -security acl -otrace_authentication -init_fil
dmadmin 9552 9511 0 Jan 02 ? 11:27 ./documentum -docbase_name secm1 -security acl -otrace_authentication -init_fil
dmadmin 9846 9511 0 Jan 02 ? 1:57 ./dm_agent_exec -docbase_name secm1.secm1kandocus02 -docbase_owner dmadmin -sle
dmadmin 9511 1 0 Jan 02 ? 2:13 ./documentum -docbase_name secm1 -security acl -otrace_authentication -init_fil dmadmin 9847 9511 0 Jan 02 ? 1:13 ./documentum -docbase_name secm1 -security acl -otrace_authentication -init_fil
dmadmin 9556 9511 0 Jan 02 ? 0:00 ./documentum -docbase_name secm1 -security acl -otrace_authentication -init_fil
dmadmin 9554 9511 0 Jan 02 ? 0:00 ./documentum -docbase_name secm1 -security acl -otrace_authentication -init_fil


As you can see a set of processes, the root process is the "dmadmin 9511 1 "
The only problem is how can i filter it out in my script. I am not very good in awk, can you guys help, a simple grep is looking up for everything which has 1 in it. I just need the line which has "9511 1 ". Basically need to filter out this line which has the Root PID.


After that i can use the awk to print the pid number.
thanks
# 2  
Old 01-11-2009
Code:
awk '$2==9511 && $3==1 {print}' filename

# 3  
Old 01-11-2009
MySQL Thankyou summer cherry

Hey that was spot on SmilieSmilie, Since i am using the ps comand to fetch the above pids i can use the awk to find my result. Here is the command.

Code:
ps -aef|grep dmadmin2|grep document
dmadmin2 18264 18253  0 00:41:28 ?        0:00 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config
dmadmin2 18376 18253  0 00:42:20 ?        0:04 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config
dmadmin2 18266 18253  0 00:41:29 ?        0:00 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config
dmadmin2 18268 18253  0 00:41:30 ?        0:00 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config
dmadmin2 18262 18253  0 00:41:27 ?        1:24 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config
dmadmin2 18253     1  0 00:41:12 ?        0:12 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config

$ ps -aef|grep dmadmin2|grep document|awk '$3==1 {print}'

dmadmin2 18253     1  0 00:41:12 ?        0:12 ./documentum -docbase_name decm1 -security acl -init_file /apps/docm/dba/config

Now i need to get the root pid from this so i modified it to

Code:
ps -aef|grep dmadmin2|grep document|awk '$3==1 {print $2}'
18253

Thankyou very much for the quick help.

Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Kill multiple processes ran by root

Hi all, I have about 5-6 daemons specific to my application running in the background. I am trying to write a script to stop them. Usually, I run them as a non-root ID, which is fine. But for some reason the client insists on using root. I do have sudo. I just tried something like this ... (4 Replies)
Discussion started by: jeffs42885
4 Replies

2. UNIX for Dummies Questions & Answers

How do I find the number of processes running on root?

Is there a certain man command I'm missing here? I searched in ps but I couldn't find something that would give me the number of processes running on root. I only want to see the number of processes, not the processes itself. (2 Replies)
Discussion started by: l3monz
2 Replies

3. Shell Programming and Scripting

Find users with root UID or GID or root home

I need to list users in /etc/passwd with root's GID or UID or /root as home directory If we have these entries in /etc/passwd root:x:0:0:root:/root:/bin/bash rootgooduser1:x:100:100::/home/gooduser1:/bin/bash baduser1:x:0:300::/home/baduser1:/bin/bash... (6 Replies)
Discussion started by: anil510
6 Replies

4. UNIX for Dummies Questions & Answers

What are these different tty processes(tty1,tty2..) running as root mentioned n the list below.

Hi, I need your help to understand about different processes(tty1,tty2,tty3...) running as root as shown below .What exactly these processes do? root@bisu-desktop:~# ps -eaf | grep -e tty -e UID UID PID PPID C STIME TTY TIME CMD root 761 1 0 10:30 tty5 ... (4 Replies)
Discussion started by: crazybisu
4 Replies

5. Shell Programming and Scripting

what is the find command to find exact dir from the root

I want to find a dir called STOP from the root.so what is the find command. Thanks & Regards Rajkumar (1 Reply)
Discussion started by: rajkumar_g
1 Replies

6. UNIX for Dummies Questions & Answers

If user has own crontab, results in accumulation of root CRON processes

Hello, I seem to be having a problem with accumulation of root CRON jobs occuring when I have a user's cron job(s) running. Here is an example of a user's crontab file: */1 * * * * echo "hello" > /dev/nullps aux|grep CRON root 14333 0.0 0.0 91236 2172 ? S ... (12 Replies)
Discussion started by: Narnie
12 Replies

7. AIX

Can't login root account due to can't find root shell

Hi, yesterday, I changed root's shell in /etc/passwd, cause a mistake then I can not log in root account (can't find correct shell). I attempted to log in single-mode, however, it prompted for single-mode's password then I type root's password but still can not log in. I'm using AIX 5L version 5.2... (2 Replies)
Discussion started by: neikel
2 Replies

8. UNIX for Advanced & Expert Users

find my tree of processes

Hi. I am logging into a remote unix/linux server (of any kind - aix, hpux, linux...) I would like to run a shell command that will return me the list of PIDs that relate to my tree. I need to get the PID of my father, and my self. I know that my SSHD process openes a BASH process. need both... (2 Replies)
Discussion started by: yamsin789
2 Replies

9. Solaris

How to find number of processes ?

Hi , I need to count all processes contains the pattren "FND" For Example: I was reteriving the details of all processes related to "FND" by this command $ ps -ef | grep FND but now I just wanna count them . Regards Adel (2 Replies)
Discussion started by: ArabOracle.com
2 Replies

10. Programming

C program to kill root processes

Hello, First let me start by saying I have searched the forum and read all the SUID stuff but it is not in the neighborhood I am looking for. Here is the problem. We want to grant a non super-user permission to kill root processes but only if the process matches certain criteria. ... (8 Replies)
Discussion started by: TioTony
8 Replies
Login or Register to Ask a Question