Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 290 Bytes

bash.md

File metadata and controls

29 lines (19 loc) · 290 Bytes

Exit on Error

set -e

Trap Signals

trap 'echo "Error occurred"; cleanup; exit 1' ERR

function cleanup() {
  # Cleanup code
  echo "Cleaning up"
}

Logging

logfile="script.log"
exec > >(tee -i $logfile)
exec 2>&1

echo "Script started"