Skip to Content
gnux

nicex

Run a program with modified scheduling priority.

Mirrors GNU nice. Run it as nicex, or as gnux nicex.

Synopsis

nicex [OPTION] [COMMAND [ARG]...]

GNU reference

Description

nicex runs COMMAND with its niceness adjusted by 10, or by -n ADJUSTMENT, so that it gets less (or, with a negative adjustment, more) CPU time than other processes. Niceness ranges from -20 (most favorable) to 19 (least); the result is clamped to that range. With no COMMAND it prints the current niceness. The obsolete forms -ADJUSTMENT and --ADJUSTMENT (negative) are accepted as in GNU: 'nicex -5 make' and 'nicex --5 make'. Options must come before COMMAND. Lowering the niceness needs privilege; without it nicex warns 'cannot set niceness' and runs the command anyway, as GNU nice does. The exit status is the command's, or 125 when nicex itself failed, 126 when COMMAND was found but could not be run and 127 when it was not found. nicex starts COMMAND as a child and sets its niceness as it starts, where GNU nice changes its own and then becomes COMMAND. On Windows, which has no niceness, the adjustment picks the nearest priority class instead (idle, below normal, normal, above normal or high; never realtime), so 'nicex make' really does lower the build's priority there too, and nicex with no COMMAND prints the niceness its own class corresponds to.

Permissions

Raising the niceness (lowering the priority) needs no privilege. Lowering it below the current value needs root (or CAP_SYS_NICE); on Windows the high priority class may need an administrator. Execute permission is needed on COMMAND.

Use cases

  • Running a long build or compression job without slowing an interactive desktop.
  • Running backups and batch jobs at low priority.
  • Giving a latency-sensitive job more CPU, as root, with a negative adjustment.
  • Checking the current niceness of a shell.
  • Lowering a job's priority the same way on Linux, macOS and Windows.

Flags

  -n, --adjustment N   add integer N to the niceness (default 10)
      --help           display this help and exit
      --version        output version information and exit

Examples

Run a build at lower priority

nicex make -j8

Run at the lowest priority

nicex -n 19 tar -czf backup.tgz data/

Use the obsolete adjustment form

nicex -5 make

Raise a job's priority (needs privilege)

sudo nicex -n -5 ./server

Raise it with the obsolete form

sudo nicex --5 ./server
nicex
nicex nicex

Combine with a time limit

nicex timeoutx 1h ./batch.sh

Pass the adjustment as a long option

nicex --adjustment=15 gzip -9 big.log

Keep the command's exit status

nicex ./tests.sh; echox "exit: $?"

Run a low-priority job from the portable gnux shell

gnux shell -c 'nicex -n 10 envx make'

Options

Each option has a page of its own, with its usage and examples.

Exit status

StatusMeaning
0success: every operand was processed
1failure: an operand could not be processed (diagnosed on standard error)
125a command-line mistake

Help in the terminal

nicex --help                # options, first examples, exit status
gnux help nicex             # this page: the full manual
gnux help nicex --OPTION    # one option in depth, with its examples

See also

On this page