Job Control#

Commands#

  • jobs
  • bg
  • fg
  • ps
  • pstree
  • pgrep
  • pidof
  • nice
  • renice
  • kill
  • pkill

Niceness and Priority#

40 niceness values. -20 is highest and 19 is lowest. Default is 0. Child processes inherit niceness of parent. Users can renice processes they own. root can renice any process.

  • nice (1) - run a program with modified scheduling priority
  • renice (1) - alter priority of running processes

Print process list with priority and niceness columns:

ps -efl
[root@server1 ~]# ps -efl | head
F S UID          PID    PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
4 S root           1       0  0  80   0 - 43106 ep_pol Mar02 ?        00:00:01 /usr/lib/systemd/systemd rhgb --switched-root --system --deserialize 31
1 S root           2       0  0  80   0 -     0 kthrea Mar02 ?        00:00:00 [kthreadd]
1 I root           3       2  0  60 -20 -     0 rescue Mar02 ?        00:00:00 [rcu_gp]
1 I root           4       2  0  60 -20 -     0 rescue Mar02 ?        00:00:00 [rcu_par_gp]
1 I root           5       2  0  60 -20 -     0 rescue Mar02 ?        00:00:00 [slub_flushwq]
1 I root           6       2  0  60 -20 -     0 rescue Mar02 ?        00:00:00 [netns]
1 I root           8       2  0  60 -20 -     0 worker Mar02 ?        00:00:00 [kworker/0:0H-events_highpri]
1 I root          10       2  0  60 -20 -     0 rescue Mar02 ?        00:00:00 [mm_percpu_wq]
1 I root          12       2  0  80   0 -     0 rcu_ta Mar02 ?        00:00:00 [rcu_tasks_kthre]

View default niceness with nice command:

[root@server1 ~]# nice
0

Process Signals#

List available signals with kill -l:

[root@server1 ~]# kill -l
 1) SIGHUP   2) SIGINT   3) SIGQUIT  4) SIGILL   5) SIGTRAP
 6) SIGABRT  7) SIGBUS   8) SIGFPE   9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG  24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF 28) SIGWINCH    29) SIGIO   30) SIGPWR
31) SIGSYS  34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX    

Most common process signals:

Signal Number Signal Name Action
1 SIGHUP Hang up signal causes a process to disconnect itself from a closed terminal that it was tied to. Also used to instruct a running daemon to re-read its configuration without a restart
2 SIGINT The ^c (Ctrl+c) signal issued on the controlling terminal to interrupt the execution of a process.
9 SIGKILL Terminates a process abruptly.
15 SIGTERM Sends a soft termination signal to stop a process in an orderly fashion. This is the default signal if none is specified with the command.
18 SIGCONT Same as using the bg command to resume.
19 SIGSTOP Same as using the Ctrl+z to suspend a job.
20 SIGTSTP Same as using the fg command.

Commands#

  • kill (1) - terminate a process
  • pkill (1) - look up, signal, or wait for processes based on name and other attributes