Created
April 16, 2021 13:26
-
-
Save Rodrigonavarro23/144e301b3a1161490279e1589dc010f2 to your computer and use it in GitHub Desktop.
Bash graceful shutdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
graceful_shutdown() { | |
echo "Exit requested..." | |
# handle your shutdown here | |
exit 0 | |
} | |
# this line exectues when process exits | |
trap 'graceful_shutdown' TERM INT HUP | |
# write your bash code here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment