I want to create a script which able to send the log file by email. The problem now is the text file I have received through email is blank. Which part is the problem?
MYSQL_SLOW_LOG_USER="****"
MYSQL_SLOW_LOG_PASSWORD="*****"
SLOW_LOG="/var/log/mysql-slow.log"
cat <<EOF | mysql -u $MYSQL_SLOW_LOG_USER -p$MYSQL_SLOW_LOG_PASSWORD
SET GLOBAL log_queries_not_using_indexes = 'OFF';
SET GLOBAL slow_query_log = 'OFF';
FLUSH SLOW LOGS;
EOF
cat $SLOW_LOG > /tmp/corpsoDB.txt
recipient="cronjobauto@yahoo.com"
(
cat - <<END
Subject: MySQL Slow Query Log Report-Corpso
Content-Type: multipart/mixed; boundary="-omgemailslikewhoa"
GET ON IT.
---omgemailslikewhoa
Content-Type: text/plain; name="corpsoDB.txt"
Content-Disposition: attachment; filename="corpsoDB.txt"
END
cat /tmp/corpsoDB.txt
cat <<END
---omgemailslikewhoa--
END
) | /usr/sbin/sendmail -i -- $recipient