14

How can i view the priority of a specific process ?

9

The top command lists the priority of running processes under the PR heading. If you have it installed, you can also search for a process and sort by priority in htop.

12

awk '{print $18}' /proc/1337/stat (gets the prio for process 1337).

Other options:

Use ps -o pri. Specify the process id with -p 1337. Or, use -e to list all processes.

Experiment with this as a starting point if you want more than just the priority:

ps -e -o uid,pid,ppid,pri,ni,cmd
5

ps is probably the right way to go. You can then grep and awk your way to the relevant row and column

3
ps -o ni $(pidof processname)

For example:

ps -o ni $(pidof mysqld)

# ps -o ni $(pidof mysqld) 
  NI
  15
2

If you have a cut-down Linux distribution where ps and top does not give you priority information, you can parse the stat file of proc for your process ID to get the priority information.

cat /proc/PID/stat | awk '{print "priority " $18 " nice " $19}'

The values at position 18 and 19 of stat file represent priority and nice

For more: https://linux.die.net/man/5/proc

0
ps -le | grep 'process name'

ps -lp 'PID of specific process'
0

You might exclude headers with --no-headers if ps have it. You could use "ps --no-headers -o pri $(pidof )" to just show priority. Use pgrep if you have no pidof.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.