I've been running the following command on my linux box:
watch -d -n 1 "cat /proc/19866/stat"
The pid above is a pid of Nginx's master process - I would expect the following fields to be changing: 14, 15, 16 and 17 as according to kernel docs those should contain amount of time the process has been scheduled in user/kernel mode (14,15) and its children too (16,17), however running this command in watch I noticed that none of those numbers ever change. Can someone shed a bit more light on this ? I'd like to count some CPU usage stats per process and I thought /proc.. was the place to look. Thanks!
Try constructing a simple shell script using the
ps
command. Based on the implementation, you can get the command to output only those fields that are interesting to you.