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:
- Users can only change the nice value of processes which they own.
- User cannot start processes with nice values less than 20
- User cannot lower the nice values of their processes after they've raised them.
- 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:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 4 comments… read them below or add one }
perfect!
“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?
“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?
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.