The headline basically says it all. I have a program where I am only given the PID, nothing more really, and I would like to know how I get more information about the given process.
13 Answers
ps -Flww -p THE_PID will show you some information. See the ps manpage for more information about the ps command. The "STANDARD FORMAT SPECIFIERS" section explains what the different columns mean.
I don't know what is your exact requirement. but this may help you.
There is separate directory for every process with name as pid number in /proc .
ps -ef | grep docker root 1700 1 0 Sep20 ? 00:03:04 /usr/bin/docker daemon --raw-logs In above output PID is 1700 .
goto /proc/1700
cd /proc/1700 and do ls there
ls attr clear_refs cpuset fd limits mem net oom_score projid_map sessionid stat task autogroup cmdline cwd fdinfo loginuid mountinfo ns oom_score_adj root setgroups statm timers auxv comm environ gid_map map_files mounts numa_maps pagemap sched smaps status uid_map cgroup coredump_filter exe io maps mountstats oom_adj personality schedstat stack syscall wchan there is many file that have all information about process.
Like:
cat /proc/1700/status Name: docker State: S (sleeping) Tgid: 1700 Ngid: 0 Pid: 1700 PPid: 1 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 64 Groups: 0 999 VmPeak: 527576 kB VmSize: 527512 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 46032 kB VmRSS: 34180 kB VmData: 449308 kB VmStk: 136 kB VmExe: 28324 kB VmLib: 4236 kB VmPTE: 296 kB VmSwap: 5324 kB Threads: 12 SigQ: 0/63662 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: ffffffffffc1feff CapInh: 0000000000000000 CapPrm: 0000003fffffffff CapEff: 0000003fffffffff CapBnd: 0000003fffffffff Seccomp: 0 Cpus_allowed: f Cpus_allowed_list: 0-3 Mems_allowed: 00000000,00000001 Mems_allowed_list: 0 voluntary_ctxt_switches: 437726 nonvoluntary_ctxt_switches: 27579 If you need basic command to get process information then you can easily get using command:
man ps To add to the ps answer there is also the pidstat command which will show additional stats like the time spent in user mode or the occupation of the cpu. You can use it with:
# pidstat -p 51648 You can also add the -d flag to add details about I/O:
# pidstat -p 51648 -d And you can also an integer as a second parameter to make the command refresh each X seconds:
# pidstat -p 51648 3 0