LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2007, 04:59 AM   #1
vkarna
LQ Newbie
 
Registered: Oct 2007
Location: India
Distribution: Red Hat
Posts: 3

Rep: Reputation: 0
How to find owner of a process


Hello

I have 2 questions and both are in Perl context.

1. Suppose I know just the process id of a process, I want to know how can I get the process owner.

2. I know if I run a script I can know the process id by print $$ and get its parent using getppid function. But If I want to know the grandparent and its parent and so on i.e the whole process tree backwards, how can I achieve that ?

Can someone help me out here.

Thanks in advance
Vivek
 
Old 10-19-2007, 06:50 AM   #2
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Would have thought 'top' would do the first job. Type top and then look opposite the known pid. ps 'll probably have a way of doing it too, man pid.

From memory 'think there is something that does this, but have forgotten the name .... it's called pstree.
 
Old 10-19-2007, 09:58 AM   #3
vkarna
LQ Newbie
 
Registered: Oct 2007
Location: India
Distribution: Red Hat
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for your answers.

I believe I was not very clear with my question. Actually I am looking for any builtin functions within perl or linux or any cpan module which will give me this information.

You are right that I can run ps command and then parse it using awk to get the process owner and parent process id and can continue it like that way to get the whole tree backwards but I found this process a bit time consuming.

Also pstree will give the process tree out of that process id, here I want the tree backwards not forward.

Any information on a perl builtin or a capn module which can give me the process owner name given the process id would be very useful.

Thanks
 
Old 10-19-2007, 10:01 AM   #4
vkarna
LQ Newbie
 
Registered: Oct 2007
Location: India
Distribution: Red Hat
Posts: 3

Original Poster
Rep: Reputation: 0
However you are right with ps command. So if I do not get any other information, I will have no other alternatives but to use ps to get this information.

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine who the process' owner* is? balteo Linux - General 3 04-20-2013 06:40 AM
Find out the owner of a phone number? jmmbacon Linux - General 1 07-06-2007 03:43 PM
Process Owner Questions Lawrentium Linux - Security 2 11-22-2006 11:20 PM
[Apahce] How to change process owner for Apache? JockVSJock Linux - Security 3 11-21-2006 05:05 AM
apache, process owner, and rsync/ssh question Kruel Linux - Networking 0 03-01-2002 01:25 PM


All times are GMT -5. The time now is 11:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration