If this is a shell script, then you need to define the code that you want to run on exit as a function, and then set "trap" to catch the signals:
Quote:
# Function to exit the script if a termination signal is sent.
exit_withinterrupt() {
echo "ERROR: The script was canceled before completing."
}
# Set the script to catch Ctrl-C and other termination signals and run the exit function.
trap exit_withinterrupt SIGHUP SIGINT SIGQUIT SIGTERM
|
To handle crashes, use trap [function] ERR.
Hope that helps.