Last active
December 20, 2015 07:29
-
-
Save pensierinmusica/6094040 to your computer and use it in GitHub Desktop.
A simple Bash script to log server crashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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