Using Trap to Exit Bash Shell Scripts Cleanly - Linux Tutorial

Published: 06 February 2020
on channel: Putorius Linux Tutorials
4,874
120

In this Bash tutorial we will show you how to use trap to exit a script cleanly. It can be used to clean up temporary files, ensure service availability after a script exits, ensure ports are secured and much more.

A text version of this tutorial can be found here:
https://www.putorius.net/using-trap-t...

0:00 Introduction to Bash Exit Trap
0:49 What is trap?
1:31 The wrong way to clean up on script exit
2:05 How to use trap on exit to clean up temporary files
2:53 Using traps to ensure service availability
3:31 Ensure ports are closed after script exit
4:02 Using a function in a trap call
4:20 Conclusion


On this page of the site you can watch the video online Using Trap to Exit Bash Shell Scripts Cleanly - Linux Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Putorius Linux Tutorials 06 February 2020, share the link with friends and acquaintances, this video has already been watched 4,874 times on youtube and it was liked by 120 viewers. Enjoy your viewing!