Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
nice(1)			    General Commands Manual		       nice(1)

       nice - run a command at nondefault priority

       command [command_args]

       command [command_args]

       The  command  executes command at a nondefault CPU scheduling priority.
       (The name is derived from being "nice" to other system users by running
       large programs at lower priority.)

       The command-line	arguments are as follows:

	      priority_change The  difference  between	the  system nice value
			      (relative	priority) of the current  (or  parent)
			      process  and  the	 actual	 system	 nice value at
			      which command is to run.

			      An unsigned  value  increases  the  system  nice
			      value  for  command,  causing it to run at lower

			      A	negative value requires	superuser  privileges,
			      and  assigns  a  lower system nice value (higher
			      priority)	to command.  If	the current process is
			      not privileged, the value	is silently treated as
			      if it were 0.

			      If the value of priority_change would result  in
			      a	 system	nice value outside the range 0 through
			      39, the corresponding limit value	of 0 or	39  is
			      used instead.

			      Note that	a positive priority_change (lower pri-
			      ority) has a single option character before  the
			      numeric value; a negative	(higher	priority) pri-
			      ority_change has two: the	option character  fol-
			      lowed  by	the minus sign If is not specified, it
			      defaults to

	      command	      A	program, HP-UX	command,  user	shell  script,
			      etc.  to be executed at the nondefault priority.
			      command can be run as a foreground or background

			      If  command  is run as a background process, any
			      nice priority_change made	by the shell  executes
			      all  background  processes via is	in addition to
			      that specified in	the command line.

	      command_args    Any arguments recognized by command.

   Process Priorities
       All processes have an associated	system nice value  which  is  used  to
       compute	the instantaneous-priority of the process when it is scheduled
       to run.	Normally, all processes	inherit	the system nice	value of their
       parent  process	when  they are spawned.	 The shell etc.)  can create a
       child process with a different priority from the	current	shell  process
       by  spawning the	child process via the command.	If the priority_change
       value is	unsigned (positive), the child process is nicer	(lower in pri-
       ority)  relative	 to the	parent.	 If the	priority_change	value is nega-
       tive, the child process runs at a higher	priority with a	greater	 share
       of  available  system  resources.   To  spawn  a	 higher	priority child
       process,	the parent process must	be owned by a user who has the	appro-
       priate privileges.

       At  boot-up, the	system starts the process at a system nice value of 20
       (system default).  On most systems, all processes (down	to  the	 login
       shells)	inherit	 this  priority.  Starting from	their individual login
       shell processes,	users can alter	the system nice	 value	of  descendent
       processes  to as	much as	39, or,	with appropriate privileges, as	little
       as 0.  A	system nice value of 0 establishes an extremely	high priority,
       whereas a value of 39 indicates a very low priority.

       Ordinary	 users	can  only  increase the	system nice value of any child
       process relative	to the current process;	i.e., priority_change must  be
       a positive (unsigned) value, resulting in a lower priority.  To start a
       child process at	a lower	system nice value (higher priority)  than  the
       current process,	the user must have the appropriate privileges, regard-
       less of the relative nice-priority value	desired.

       For example, using the command

       from a login shell whose	current	nice value is  20  spawns  a  subshell
       with a system nice value	of 30.	Attempting to use

       from  the  new  shell to	spawn another subshell whose system nice value
       would be	28, is rejected	(unless	the user has appropriate  privileges),
       even though the resulting system	nice value would be less than the pri-
       ority of	the original login shell process.

       The system nice value for current processes is listed under the	column
       produced	by the command (see ps(1)).

   Background Processes
       Foreground  processes  are  run at same system nice value as the	parent
       shell.  Background processes spawned by run at the equivalent of	 a  by
       default.	  If  a	 background  process  is  started  via from any	prior-
       ity_change specified in the command is added to default Thus  the  com-

       runs at a system	nice value of 36 if executed from

   Environment Variables
       determines the language in which	messages are displayed.

       If  is  not specified in	the environment	or is set to the empty string,
       the value of is used as a default for each unspecified or  empty	 vari-
       able.   If is not specified or is set to	the empty string, a default of
       "C" (see	lang(5)) is used instead of

       If any internationalization variable contains an	invalid	 setting,  be-
       haves as	if all internationalization variables are set to "C".  See en-

   International Code Set Support
       Single- and multi-byte character	code sets are supported.

       returns the value returned by command.

       The following examples assume the current process  is  running  with  a
       system  nice  value  of	20  and	 is  executed from the Korn shell (see

       Run a program named in the current  directory  at  the  default	prior-
       ity_change of 10	(system	nice value of 30):

       Run  the	same program in	the background using a system nice value of 36
       (priority_change=12 plus	4 for the Korn shell):

       As a user with appropriate privileges, run as a foreground process with
       a system	nice value of 6:

       The  C shell, has a built-in command with different syntax.  See	csh(1)
       for details.

       csh(1), ksh(1), nohup(1), sh-posix(1), sh(1), renice(1M), nice(2).



Want to link to this manual page? Use this URL:

home | help