Skip to content

Instantly share code, notes, and snippets.

@Rodrigonavarro23
Created April 16, 2021 13:26
Show Gist options
  • Save Rodrigonavarro23/144e301b3a1161490279e1589dc010f2 to your computer and use it in GitHub Desktop.
Save Rodrigonavarro23/144e301b3a1161490279e1589dc010f2 to your computer and use it in GitHub Desktop.
Bash graceful shutdown
#!/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