Priority & Background Jobs
Nice Values (Priority)
Nice ranges from -20 (highest priority) to +19 (lowest). Only root can set negative values.
$ nice -n 10 ./batch.sh # start with lower priority
$ renice -n 5 -p 1234 # change a running process
Job Control
| Command | Action |
|---|---|
cmd & | Start in background |
Ctrl+Z | Suspend current job |
jobs | List shell jobs |
bg %1 | Resume job 1 in background |
fg %1 | Bring job 1 to foreground |
nohup cmd & | Survive logout |
disown | Detach from shell |
Exam tip:nohup+&(ordisown) keeps a job running after the terminal closes because it ignores SIGHUP.