Use the trap command of linux to specify the action to take
Do not know how to use linux's trap command to specify the action to be taken? In fact, it is not difficult to solve this problem. Let the editor take you to learn how to solve it. I hope you will gain a lot after reading this article.
The trap command is used to specify the action to be taken after a signal is received, and a common use is to clean up when the script is interrupted. When shell receives the signal specified by sigspec, the arg parameter (command) will be read and executed.
Syntax format: trap [parameters]
Common parameters:
-l have shell print a list of command names and their corresponding numbers-p print a list of commands associated with each signal. By default, each received sigspec signal will be reset to its value when it enters the shell-f blocks the interrupt signal.
Reference example
Clean up temporary files:
[root@linuxcool ~] $trap "rm-f $WORKDIR/work1 $$WORKDIR/dataout$; exit" 2
Ignore the signal:
[root@linuxcool ~] $trap''2
The default action to restore the signal:
[root@linuxcool ~] $trap 2
Stop the interrupt operation signal:
[root@linuxcool] $tail-f / var/log/test Thank you for reading this article carefully. I hope it is helpful for the editor to share the actions specified by linux's trap command. At the same time, I also hope you can support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!