Nice Command

Linux nice command is Run Process With Modified Scheduling Priority ( nicenesses ). With the help of Nice command in Linux you can set process priority. If you give a process a higher priority, then Kernel will allocate more cpu time to that process.

By default when a programe is launched in Linux, it gets launched with the priority of ‘0’. However you can change the priority of your programes by either of the following methods.

You can launch a programe with your required priority. Or you can also change the priority of an already running process.

Process priority values range from -20 to 19. A process with the nice value of -20 is considered to be on top of the priority. And a process with nice value of 19 is considered to be low on the priority list.

You can use ps -al, top and various command to check priority. The column that starts with “NI” shows the nice value(priority of the process). You can clearly see that most of them has got a ‘0’ priority.

31102 nobody    16   0  269m  22m  10m R  2.0  0.6   0:04.44 /usr/local/apache/bin/httpd -k start -DSSL
27956 root      15   0 12884 1268  832 R  1.0  0.0   2:53.60 top -c
22384 mysql      5 -10 2830m 204m 3864 S  0.7  5.2 372:40.00 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/serv.med1med
1 root      15   0 10368  584  552 S  0.0  0.0   0:03.09 init [3]
2 root      RT  -5     0    0    0 S  0.0  0.0   0:06.15 [migration/0]
3 root      34  19     0    0    0 S  0.0  0.0   0:00.28 [ksoftirqd/0]
4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 [watchdog/0]

For example

nice -10 <command name> Will set a process with the priority of “10”.

Renice Command

In order to change the priority of an already running process you can use “renice” command.

Suppose you see that your machine is running slow due to some lengthy process(which is not a required process at the moment), then you can reduce the priority of that process with the help of renice command. And also increase the priority of your required process at the moment.

renice command is very much similar to the nice command( interms of options in priority), however it does differ slightly in terms of parameters. You can give username,groupname etc in renice command as a parameter.


renice 15 -p 20380 (this will set the priority of process id no 20380 to 15)

renice -17 -p 24132 -u mysql (this will set the priority of the process id 24132 to -17)

renice 11 -u cpanel,nobody -g testuser (this will set all process owned by “cpanel”,”nobody” and also the group “testuser” to 11)


Get Free cPanel Knowledge Base

Thank you for subscribing.

Something went wrong.

5.00 avg. rating (96% score) - 1 vote