renice command: Change the Priority of a Already Running Process

by on February 26, 2008 · 4 comments· last updated at February 26, 2008

Q. I'd like alter / change the scheduling priority of running processes. How do I change the Priority of a already running process under CentOS Linux or any UNIX like operating systems?

A. If you run CPU-bond processes you must use nice command used to start process with modified scheduling priority / nicenesses. renice command is used to change the priority of a process that's already running.

renice command syntax:

The renice command changes the nice value of a process already running. It's syntax is as follows:
renice {priority} pid
The following will change nice value of process 2243 to 19, enter:
# renice 19 2243
The following will change the priority of process ID’s 1024 and all processes owned by users vivek, enter:
# renice +1 1024 -u vivek
The following will change the priority of process ID’s 1024 and 66, and all processes owned by users daemon and root.
# renice +1 1024 -u daemon root -p 66
Please note that:

  1. Users can only change the nice value of processes which they own.
  2. User cannot start processes with nice values less than 20
  3. User cannot lower the nice values of their processes after they've raised them.
  4. As usual root has full access to renice command

For more details and options see renice command man page:
$ man renice



You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 4 comments… read them below or add one }

1 Sarika June 13, 2008 at 2:37 am

perfect!

Reply

2 Nudge January 30, 2010 at 2:11 pm

“2. User cannot start processes with nice values less than 20″:

That’s not really correct. It is possible for users to go down to nice value 0, e.g. by not using the nice command when starting processes. This results in processes having *priority* 20. Prority and nice-values belong together (NI 0 => PR 20, NI 19 => PR 39, NI -20 => PR 0).

According to the manual, renice can use delta values like +3 or -2 for changing nice values, but to me it seems unclear what happens when entering “renice -5 ” as root – does that mean a nice value of -5 or lowering the existing nice value by 5?

Reply

3 Simon March 15, 2010 at 11:57 pm

“to me it seems unclear what happens when entering “renice -5 ” as root – does that mean a nice value of -5 or lowering the existing nice value by 5?”

Great question. I too am still confused by the usage of this command. This also seems quite strange to me…

“User cannot lower the nice values of their processes after they’ve raised them.” Why would that be?

Reply

4 Cameron February 15, 2011 at 3:26 am

I was curious about the question in the comments, so I did a little test:

cameron$ echo “fib=lambda n: (n in (0,1) and [n] or [fib(n-1)+fib(n-2)])[0];print fib(38)” | python &
[1] 76611
cameron$ ps -o command,pid,pri,ni -p 76611
COMMAND PID PRI NI
python 76611 31 0
cameron$ sudo renice -4 76611
cameron$ ps -o command,pid,pri,ni -p 76611
COMMAND PID PRI NI
python 76611 35 -4
cameron$ sudo renice -5 76611
cameron$ ps -o command,pid,pri,ni -p 76611
COMMAND PID PRI NI
python 76611 36 -5

so, it looks like the command sets the nice value to the given value, rather than moving it relative to what is was before.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , , , , ,

Previous Faq:

Next Faq: