O'Reilly logo

Mastering Bash by Giorgio Zarrelli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Job controls

So, we have the  job ID, process ID, foreground, and background processes, but how do we control these jobs? We have a bunch of commands available, let's have a look at how to use them:

  • kill: We can pass the job ID to this command, which will send the SIGTERM signal to all the processes belonging to the job itself:
zarrelli:~$ sleep 100 &[1] 9909zarrelli:~$ kill %1zarrelli:~$ [1]+ Terminated sleep 100

You can also pass to kill a specific signal to send to the process. For instance, kill -15 will nicely terminate a process with a SIGTERM signal, and if it refuses to die, kill -9  will send a SIGKILL, which will instantly terminate a process. Which signals can we send to a process? Either kill -l or  cat /usr/include/asm-generic/signal.h ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required