To pause or stop a process, we can either use keyboard shortcuts or send a signal to our process. Let's look at the keyboard shortcuts first, then dive into what sending signals is all about.
To interrupt a process, press ctrl+c. This interrupts the program by sending it a
INT (interrupt) signal.
To pause a process, press ctrl+z. This sends the program a TSTP command (Terminal Stop).
This is especially useful if you want to pause a program and come back to it later. For example, we could have Python running, then press ctrl+z. This will place Python to the background. If you want to return to Python, simply type
fg %1, and you'll be back where you left off.
Keyboard shortcuts are simply a convenient way to sending signals to jobs in our foreground.
As we have just seen, ctrl+c sends an
INT signal (for interrupt), and ctrl+z sends a
TSTP signal (terminal stop).
Besides sending an
INT (interrupt) or
TSTP (terminal stop) signal, there are many more signals that we can use with the
To use this command, specify a signal as the option, with the PID or the jobspec.
$ kill -s signal pid
If no signal is mentioned, the default signal is
Here is a list of Unix signals, which you may also see with the
kill -l command. When specifying the signal, you may either use the shortened word form, or its integer value. We've included an asterisk next to a signal to denote the most commonly used signals.
Here are a few examples with the above signals.
$ kill -3 13569 # Quits out of process with PID 13569 $ kill -INT 1239 # Interrupts process with PID 1239.
Even without the
kill command, a process can be shutdown. For instance, if you
ssh into a computer, start up a process, then logout, a SIGHUP command will be sent out, and your program will be shut down.
To prevent your process to shutting down, precede the process invokation with the
$ nohup python3 MyRedditBot.py
To shut down multiple processes, use the
killall command. This command uses a process' name instead of its PID. You may also place in the
-i option so that the terminal asks for confirmation before shutting down a process.
The following command will terminal all programs with the name
$ killall gedit
Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.$$ Check price
Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.$ Check price