nice and renice command usages

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)

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

cPHulk Brute Force Protection

WHM/cPanel has a service, protected from Brute Force attack, which is called “cPHulk Brute Force...

Enable SSH key authorized login without root password

You need to generate SSH Key ( the private key )on your cpanel server and then update remote...

How can I Redirect URLs in cPanel

Login your cpanel 1. Click the Redirects button on the front page under the “domains” 2. Enter...

Enable Custom php.ini for Fast CGI

With fast-cgi, custom php.ini needs to be in the cgi-bin folder. 1) Move php.ini to cgi-bin...

ConfigServer Firewall CSF installation

ConfigServer firewall is a popular linux firewall security suite. It is easy to install, flexible...

Powered by WHMCompleteSolution