CHAPTER 16Script Control
As you start building advanced scripts, you'll probably wonder how to run and control them on your Linux system. So far in this book, the only way we've run scripts is directly from the command-line interface in real-time mode. This isn't the only way to execute scripts in Linux. Quite a few options are available for running your shell scripts. There are also options for controlling your scripts. Various control methods include sending signals to your script, modifying a script's priority, and switching the run mode while a script is running. This chapter examines the various ways you can control your shell scripts.
Handling Signals
Linux uses signals to communicate with processes running on the system. Chapter 4, “More Bash Shell Commands,” described the different Linux signals and how the Linux system uses these signals to stop, start, and kill processes. You can control the operation of your shell script by programming the script to perform certain commands when it receives specific signals.
Signaling the Bash shell
There are more than 30 Linux signals that can be generated by the system and applications. Table 16-1 lists the most common Linux system signals that you'll run across in your shell script writing.
TABLE 16-1 Linux Signals
Signal | Value | Description |
---|---|---|
1 |
SIGHUP |
Get Linux Command Line and Shell Scripting Bible, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.