Script for optimizing MySQL

Medical Technology, Healthcare & Government IT

.
Categories
Category Groups

#!/bin/bash

SERVICE=’mysql’

echo “In Server MySQL weekly maintenance started at $(date +”%Y-%m-%d”) ” | mailx -s ‘MySQL Weekly Maintenance started’ geopc@citrusinformatics.com roni@citrusinformatics.com sarji@citrusinformatics.com

for DATABASE in activecollab_prime cloud_db hitsphere medigy_edge_devl medigy_edge_devl_pw netspective_narthex_db ryohee_mecars
do
echo “############### $DATABASE ###############”
echo ” ————— Analyzing $DATABASE: —————”
mysqlcheck -u root -ppassword -a $DATABASE
# print the exit code
ANALYZE=$?
[ $ANALYZE -eq 0 ] && echo “====>> Result: Analyzing $DATABASE Succeed”
[ $ANALYZE -ne 0 ] && echo “====>> Analyzing $DATABASE Failed”

echo ” ————— Repairing $DATABASE: —————”
mysqlcheck -u root -ppassword -r $DATABASE
# print the exit code
REPAIR=$?
[ $REPAIR -eq 0 ] && echo “====>> Repairing $DATABASE Succeed”
[ $REPAIR -ne 0 ] && echo “====>>> Repairing $DATABASE Failed”

echo “————— Optimizing $DATABASE: —————”
mysqlcheck -u root -ppassword -o $DATABASE
# print the exit code
OPTIMIZE=$?
[ $OPTIMIZE -eq 0 ] && echo “====>> Optimizing $DATABASE Succeed”
[ $OPTIMIZE -ne 0 ] && echo “====>> Optimizing $DATABASE Failed”

echo ” ****************************************** ”
done

# Restarting MySQL
/etc/init.d/mysql restart
RESTART=$?
[ $RESTART -eq 0 ] && echo “====>> Restart Succeed”
[ $RESTART -ne 0 ] && echo “====>> Restart Failed”

#Checking MySQL Service
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo “$SERVICE service running, everything is fine”
else
echo “$SERVICE is not running”
/etc/init.d/mysql start
fi

# Completed
echo “Completed Sending Mail”
echo “In Server MySQL weekly maintenance completed at $(date +”%Y-%m-%d”). Check log file for further details. ” | mailx -s ‘MySQL Weekly Maintenance Completed’ geopc@citrusinformatics.com roni@citrusinformatics.com sarji@citrusinformatics.com
MAIL=$?
[ $MAIL -eq 0 ] && echo “====>> Mail Sent”
[ $MAIL -ne 0 ] && echo “====>> Mail Failed”

levitra for sale, acquire lioresal

Original Link