Skip to content

Instantly share code, notes, and snippets.

@ataliba
Created September 28, 2016 19:55
Show Gist options
  • Save ataliba/4661482fce10d34174658c0a09c6e52a to your computer and use it in GitHub Desktop.
Save ataliba/4661482fce10d34174658c0a09c6e52a to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Mysql-test
# A little script to test if you mysql or mariadb is running.
# If the database is up, only logs, if the database is down, the script starts the database again
# Test on a Ubuntu Server
#
# Author: Ataliba Teixeira
#
#########################################################################
mysqladmin ping > /dev/null 2>&1 && up=1 || up=0
if [ $up -eq 0 ] ; then
/sbin/systemctl restart mysql.service
/usr/bin/logger -t Mysql-test "O mysql estava parado e foi reiniciado"
else
/usr/bin/logger -t Mysql-test "O mysql esta rodando"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment