Skip to content

Instantly share code, notes, and snippets.

@rummykhan
Created July 26, 2017 11:24
Show Gist options
  • Save rummykhan/bd1c88d9284f9cae60ad5b78100abfb0 to your computer and use it in GitHub Desktop.
Save rummykhan/bd1c88d9284f9cae60ad5b78100abfb0 to your computer and use it in GitHub Desktop.
#!/bin/bash
function send_email () {
echo sending email;
}
mongo --eval "db.stats()" > /dev/null # do a simple harmless command of some sort
RESULT=$? # returns 0 if mongo eval succeeds
if [ $RESULT -ne 0 ]; then
send_email
`systemctl start mongodb`
exit 1
else
echo "mongodb running!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment