Which files does the linux command "top" read from in order to build its table of data? Specifically, I'd like to be able to find the data for the "command" column based off of a PID.
feedback
|
|
It's in /proc/$pid/cmdline. The fields are nul separated. Example on my machine:
| |||
|
feedback
|
|
top gets its information from the files found in procfs aka /proc you can query based off the pid by using
unfortunately i don't recall the syntax of the command... | |||||
feedback
|
|
You can use ps to get the name of the command link to a particular PID
It will also give you additional information based on the parameters you pass. See here for more details. Alternatively you can download the top source code which should give you a more precise answer to the question. Also this PerlMonks article explains how to simulate top on a AIX system, which also makes use of the ps command. | |||||||
feedback
|