System Administration Guide: Advanced Administration

ProcedureHow to Change the Priority of a Process (nice)

Using this procedure, a user can lower the priority of a process. However, superuser can raise or lower the priority of a process.


Note –

This section describes the syntax of the /usr/bin/nice command and not the C-shell built-in nicecommand. For information about the C-shell nice command, see the csh(1) man page.


  1. Determine whether you want to change the priority of a process, either as a user or as superuser. Then, select one of the following:

    • As a user, follow the examples in Step 2 to lower the priority of a command.

    • As a superuser, follow the examples in Step 3 to raise or lower priorities of a command.

  2. As a user, lower the priority of a command by increasing the nice number.

    The following nice command executes command-name with a lower priority by raising the nice number by 5 units.


    $ /usr/bin/nice -5 command-name
    

    In the preceding command, the minus sign designates that what follows is an option. This command could also be specified as follows:


    % /usr/bin/nice -n 5 command-name
    

    The following nice command lowers the priority of command-name by raising the nice number by the default increment of 10 units, but not beyond the maximum value of 39.


    % /usr/bin/nice command-name
    
  3. As superuser or assuming an equivalent role, raise or lower the priority of a command by changing the nice number.

    The following nice command raises the priority of command-name by lowering the nice number by 10 units, but not below the minimum value of 0.


    # /usr/bin/nice --10 command-name
    

    In the preceding command, the first minus sign designates that what follows is an option. The second minus sign indicates a negative number.

    The following nice command lowers the priority of command-name by raising the nice number by 5 units, but not beyond the maximum value of 39.


    # /usr/bin/nice -5 command-name
    
See Also

For more information, see the nice(1) man page.