How to check my niceness?
Is there any way to check my nice lvl? I did try with ps
, but for some reason the output does not show the column NI which is meant to show the lvl priority if I'm not wrong.
ps -fl -c
F S UID PID PPID CLS PRI ADDR SZ WCHAN STIME TTY TIME CMD
0 S sebas 9761 26810 TS 19 - 6564 wait 18:07 pts/4 00:00:00 bash
0 R sebas 25389 9761 TS 19 - 5661 - 18:27 pts/4 00:00:00 ps -fl -c
The -o flag allows you to specify columns. If you want to see your nice level, this would be in the NI column. So to see all processes with their nice level, do something like:
ps ax -o pid,ni,cmdThis will list the process ID, the nice level, and the actual command.
Example:
$ps ax -o pid,ni,cmd
PID NI CMD
1 0 /sbin/init
2 -5 [kthreadd]
3 - [migration/0]
4 -5 [ksoftirqd/0]
5 - [watchdog/0]
6 - [migration/1]
7 -5 [ksoftirqd/1]
8 - [watchdog/1]
I suggest you to use htop
. It is a great monitoring application which also shows you the niceness of each process running on your box.
There is an easier way than using the -o
flag. The -l (lowercase L) flag of the ps command displays the nice values and current priority values of the specified processes.
ps -l PID
ps -lu USERNAME
- Blatantly swiped from IBM, https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.performance/display_process_prior_ps.htm
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.