You can also use the /proc
filesystem. If you want to find the nice level of process 3236, type:
cat /proc/3236/stat
The process priority (a positive integer: bigger means higher scheduling priority) and the nice level are fields 18 and 19. Unfortunately, the nice value is printed as an unsigned integer, which means, if it's negative, that it will appear as a large integer near 2^32. For instance, I started process 3236 with the command /bin/nice -n 19 python
. This is what /proc/3236/stat looks like:
3236 (python) R 3230 3226 2145 34816 0 0 0 0 0 0 413750 51571 42 82 1 4294967277 4 0 21169489 267072106496 1718609 18446744073709551615 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The priority and nice values are 1 and 4294967277. 4294967277 is -19 rendered as a 32-bit unsigned integer. /proc
is convenient if you want to examine properties of a process in a program.
Here is the man page for the /proc
filesystem.