nice – making things run slower

nice – making things run slower

nice. That’s what you use if you want something to run
nicely.  If you have a busy box, you may hesitate to run something which might slow
the box down.  For example, when I make a port on my webserver, I issue the following
command:

nice -15 make

From man nice:

DESCRIPTION Nice runs command at a low priority. (Think of low and
slow). If -number is not given nice assumed the value 10. The
priority is a value in the range -20 to 20. The default priority is
0, priority 20 is the lowest possible. Nice will execute command at
priority number relative to the priority of nice. Higher priorities
than the current process priority can only requested by the 
super-user. Negative numbers are ex- pressed as --number.

This means that the make will run as quickly as it can, but will wait for other
processes with a higher priority number.  In effect, this make will only use the
spare resources of the box.  This might be useful for some situations.

You can also use nice on cron jobs:

#
# cvsup our ports
#
15 4 * * * root  nice -15 /usr/local/bin/cvsup -P m 
      /usr/home/ports-supfile 2>&1 | mail -s "buff Ports cvsup" root

Note: the above has been split onto two lines for ease of reading.

csh, tcsh, and perhaps other shells have a a built in nice
command, with a slightly different syntax.  This won’t affect cron jobs (which
normally run in the sh shell), but it will affect command-line use of nice.

renice

If you to change the priority of a process, use the renice
command.

Leave a Comment

Scroll to Top