🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

nice Command

Intermediate Process Management man(1)

Run a command with modified scheduling priority

👁 9 views 📅 Updated: Mar 15, 2026
SYNTAX
nice [OPTION]... COMMAND

What Does nice Do?

nice runs a command with a modified scheduling priority. The niceness value ranges from -20 (highest priority) to 19 (lowest priority). The default niceness is 0.

Higher niceness means the process is "nicer" to other processes — it yields CPU time. Lower (negative) niceness means the process takes priority. Only root can set negative niceness values.

nice is essential for running CPU-intensive tasks without impacting system responsiveness. Use it for backups, compilations, batch processing, and any long-running task that should not starve other processes.

Options & Flags

OptionDescriptionExample
-n Set niceness adjustment value nice -n 10 make -j4
default Without -n, uses niceness 10 nice make
negative Higher priority (root only) sudo nice -n -5 critical-process
range Values from -20 to 19 nice -n 19 lowest-priority-task

Practical Examples

#1 Run with low priority

Compiles code using all cores but at low priority so the system stays responsive.
$ nice -n 15 make -j$(nproc)

#2 Default nice

Runs with niceness 10 (default nice increment).
$ nice tar czf backup.tar.gz /home/

#3 Lowest priority

Runs cleanup at the lowest possible priority.
$ nice -n 19 find / -name "*.log" -mtime +30 -delete

#4 High priority (root)

Starts a critical service with higher priority than normal processes.
$ sudo nice -n -10 critical-service

#5 Background job with nice

Runs a backup sync in the background at lowest priority.
$ nice -n 19 rsync -av /data/ /backup/ &

#6 Check current niceness

Shows the current niceness value of the shell.
$ nice

Tips & Best Practices

Always nice background jobs: Use nice -n 19 for backups, builds, and batch jobs. This prevents them from making the system sluggish for interactive users.
renice for running processes: nice sets priority at launch. To change priority of an already running process, use renice: renice -n 10 -p PID.
Negative values need root: Only root can set negative niceness (higher priority). Regular users can only increase niceness (lower priority).

Frequently Asked Questions

What niceness value should I use?
10-19 for background tasks (lower priority). 0 for normal tasks. Negative values (root only) for time-critical tasks. 19 is the safest for non-urgent work.
How do I change priority of a running process?
Use renice: renice -n 10 -p PID. Or from top/htop, press r and enter the new niceness value.
Does nice affect I/O priority too?
No, nice only affects CPU scheduling priority. For I/O priority, use ionice: ionice -c3 command runs with idle I/O priority.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →