Difference between nice and setpriority in unix Difference between nice and setpriority in unix unix unix

Difference between nice and setpriority in unix


It's historical. nice() was introduced long before setpriority(). For backwards compatibility, the nice function was retained.


nice sets your own priority (the niceness of the current process). setpriority lets you set the niceness of other processes (or process groups or users). Think of it as renice.

man 3p nice

int nice(int incr);

man 3p setpriority

int setpriority(int which, id_t who, int value);


nice() modifies the nice value of the current process relative to its current nice value, so the process doesn't need to know about its starting nice value, it only cares that it should be nicer to the system (e.g: a process launches a child who does some background processing, the child sets itself to be nice).

setpriority() use case is the user explicitly setting absolute nice values to specific processes.