Skip to content

Instantly share code, notes, and snippets.

@PaulChana
Created January 22, 2018 10:44
Show Gist options
  • Save PaulChana/941a8330751d7529280ab48920365f82 to your computer and use it in GitHub Desktop.
Save PaulChana/941a8330751d7529280ab48920365f82 to your computer and use it in GitHub Desktop.
[Bash Traps] Trap signals in bash #shell #bash
# !/bin/sh
function cleanup() {
rm -rf "${BUILD_DIR}"
rm -f "${LOCK_FILE}"
# get rid of /tmp detritus, leaving anything accessed 2 days ago+
find "${BUILD_DIR_BASE}"/* -type d -atime +1 | rm -rf
echo "cleanup done"
}
trap cleanup TERM INT QUIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment