Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

snice

Change the scheduling priority of processes selected by user, tty, pid, or command.

Description

snice is the obsolete predecessor of renice; both tools are kept for compatibility, but new use cases should prefer renice. The CLI follows procps-ng’s convention where the priority adjustment is given as a leading +N or -N argument (e.g. snice +7 -u alice).

The default priority is +4 (a small step toward “nicer” / lower priority).

Inputs

  • setpriority(2) via libc::setpriority (with PRIO_PROCESS).
  • /proc/[pid]/{stat,status,cmdline} via the shared procmatch module for selection.

Synopsis

snice [new priority] [options] <expression>

expression is a list of bare PIDs (interpreted in conjunction with -p). Selectors with explicit flags can be mixed with bare PIDs.

Arguments

FlagDescription
+N / -N (leading)New nice value. Range typically -20 (highest priority) to +20 (lowest). Default: +4
--priority NSame as the leading-flag form, but in long-flag style
-n, --no-actionDon’t change priority; just print matching PIDs
-v, --verbosePrint the PID, comm, and applied priority for each process
-t, --tty TTYMatch processes whose controlling tty is TTY (repeatable)
-u, --user USERMatch processes whose effective user is USER (repeatable)
-p, --pid PIDMatch processes by PID (repeatable)
-c, --command CMDMatch processes whose comm is exactly CMD (repeatable)
--help / -V, --versionHelp / version

The priority can appear anywhere on the command line; it is rewritten internally to --priority N before clap parses argv (see preprocess_argv). Bare positional integers are added to the PID list.

Behavior

Calls setpriority(PRIO_PROCESS, pid, N) for each matched process. Negative priority values require the appropriate capability (typically CAP_SYS_NICE or root); a process without that privilege will see EPERM for any negative N.

Notes

  • -i (interactive), -f (fast), -w (warnings) and --ns / --nslist are listed in the upstream man page but not implemented here.

Exit codes

CodeMeaning
0At least one process matched and had its priority adjusted
1No processes matched, or all setpriority calls failed
2Usage error (no expression given, invalid argument)