Skip to content

Instantly share code, notes, and snippets.

@pensierinmusica
Last active December 20, 2015 07:29
Show Gist options
  • Save pensierinmusica/6094040 to your computer and use it in GitHub Desktop.
Save pensierinmusica/6094040 to your computer and use it in GitHub Desktop.
A simple Bash script to log server crashes
## Subsitute "SERVER" with your server app and "FILE" with your filename
if [ ! -d ./logs ]; then
mkdir logs
fi
SERVER FILE 2> ./logs/server-crash.last
printf '\n On ' >> ./logs/server-crash.last
echo `date` >> ./logs/server-crash.last
printf '\n------------------------------------\n' >> ./logs/server-crash.last
cat ./logs/server-crash.last | tee -a ./logs/server-crash.log
# If you want to be notified by email when the server crashes
# uncomment the next line and fill the "XXX" fields
# echo "The XXX server crashed, check it out!" | mail -s "XXX server problem" [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment