Skip to content

Instantly share code, notes, and snippets.

@stampycode
Last active June 15, 2016 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stampycode/bc1a8cb83c06fd5002bb4fa6292086b9 to your computer and use it in GitHub Desktop.
Save stampycode/bc1a8cb83c06fd5002bb4fa6292086b9 to your computer and use it in GitHub Desktop.
utility script for recording the memory in use on a server and emailing and clearing the log intermittently
#!/bin/bash
EMAIL=<insert your email here>
cd /home/ec2-user
if [[ $1 == "send" ]] ; then
sleep 5
cat memlog | /usr/bin/sendmail -F"MemLog <$EMAIL>" $EMAIL
echo > memlog
echo `/bin/date +"%Y-%m-%d %H:%I:%S"` `/usr/bin/free -m |grep total` >> memlog
exit
fi
echo `/bin/date +"%Y-%m-%d %H:%I:%S"` `/usr/bin/free -m |grep Mem` >> memlog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment