home · notes

Unix commands - nice

The nice command allows you to start a process with a specific priority level. In Unix-like systems, process priorities range from -20 (highest priority) to 19 (lowest priority). By default, a process starts with 0.

To start a process with a lower priority (giving other processes more CPU time), use:

nice -n 10 some_command

Here, some_command runs with a niceness of 10, making it less CPU-hungry compared to others.

If you need to increase priority, a negative value can be used:

sudo nice -n -5 some_command

Since only the superuser can decrease niceness (increase priority), you need sudo.

renice

If a process is already running, you can change its priority with renice:

renice -n 5 -p 1234

This modifies the priority of the process with PID 1234 to 5.