Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How do I display all current process in Unix in details and it's source files?

The report I want is similar to Daily Process Log in cPanel ex:

bookysma    bookysma.com    0.7     httpd [bookysma.com] [/images/Maple_Syrup.jpg]

Appreciate any help. Thank you.

share|improve this question
1  
what you are asking for is a little confusing given the fields in the documentation for daily process log so you might want to provide some more detail –  Tom H May 20 '12 at 7:33

2 Answers 2

A list of all the running processes can be generated using the ps tool like so;

# ps -ef 
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 May16 ?        00:00:01 /sbin/init
root         2     0  0 May16 ?        00:00:00 [kthreadd]
root         3     2  0 May16 ?        00:00:55 [ksoftirqd/0]
root         6     2  0 May16 ?        00:00:00 [migration/0]

...snip...

to see which files are currently open for ALL the process you can do;

 # lsof -P | grep REG
 .... lots of output

if you want to get all the files open by some particular service such as httpd you can do something like this;

#  ps axo comm,pgrp | grep httpd
httpd           15791

and then use that process group id, to select all the files opened by httpd and its children like so;

# lsof -P -g 15791 | grep REG
httpd   24774 15791 apache  mem    REG    253,0     15104   141783 /lib64/libcom_err.so.2.1
httpd   24774 15791 apache  mem    REG    253,0    177680   171892 /lib64/libk5crypto.so.3.1
httpd   24774 15791 apache  mem    REG    253,0    911816   171937 /lib64/libkrb5.so.3.3
... snip
share|improve this answer

run the top command and then press c

It will list which command is running for a process.

Other than that you can alwasy redirect the all the running process information from top to a file

top -b -c -M >

This will list all the prcesses with command and Memory in MB's so you have a clean output.

Additionally you can put this command in a script and run it according to your needs through cron.

Thanks.. Sandeep

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.