LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   what/who started that process (https://www.linuxquestions.org/questions/linux-general-1/what-who-started-that-process-597243/)

unkie888 11-05-2007 06:47 AM

what/who started that process
 
Is there anyway in linux to know who/what started a process - AFTER that process has complete?

rjlee 11-05-2007 07:49 AM

In general, no. Once a process has completed, it is removed from the kernel's process queues.

If the kernel held on to memory about processes after they had run then it would eventually run out of memory, not to mention the fact that you would run out of PID numbers very quickly.

While a process is running you can use the ps and pstree command to give you that kind of information; for more details see
Code:

man ps; man pstree
If you are interested in recording that kind of information then you could set up a cron job like this:
Code:

crontab -e
then add this line:
Code:

* * * * * sh -c "date; ps axo user,pid,ppid,tty,command" >> ~/ps.log
This will run once a second and append to the file ~/ps.log. You can then read it to see information about a particular process, including the PID, parent PID, user it's started by and terminal it's running on. But this will grow very big very fast, so you may want to either truncate the file periodically and/or run it less often at the risk of missing your process if it completes in less than a minute.

unkie888 11-05-2007 08:05 AM

thanks, i thought that.

the tip is kewl.


All times are GMT -5. The time now is 05:31 PM.