Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to create a program that logs all the processes started by the user and confirms after they are started. I don't want to log all the syscalls and other daemon processes. I have initially checked out auditctl and ausearch in auditd package and also acct but they are very slow and they provide much more information than I need. I want something like ps (that reports a snapshot of the current processes).

Currently I am using Ubuntu 12.04 LTS on an AMD X2 and on an Intel dual core. Thanks!

share|improve this question
1  
How about using ps then - what doesn't it do that you need? –  Paul Mar 23 '13 at 8:28
    
I ll be more precise here . I just want to put a notification to the user when the program is up and running something like an alert command for every processes. I am using bash and C/Cpp for the scripting and programming respectively. –  quick- Mar 24 '13 at 4:13

1 Answer 1

Since you did not specify a programming language for your program, i am going to recommend using Python. There are a number of ways to find out the current running processes:

a) Use the subprocess module to call ps and then parse its output. It is not pretty, but it can be done.

b) Use a third party python module like psutil or psi.

c) Since you use linux, you can look at the /proc filesystem:

import os
pids= [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
    print open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
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.