0

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
  • Look at the received mail source : is it really empty or is it invalid and not displayed in normal mode ? – Dom Sep 14 '20 at 06:11
  • @Dom where to look? what is received mail source? – user591641 Sep 14 '20 at 07:04
  • @Dom , this is the email I received https://drive.google.com/file/d/1jnNuezyWxYAdNW_ZZ9ZvG1MG3ZJFLaBc/view?usp=sharing – user591641 Sep 14 '20 at 07:09
  • I don't know Yahoo mail, but you should found a button to see the source (the mail in raw text). You will see your boundaries "---omgemailslikewhoa" by example – Dom Sep 14 '20 at 11:12
  • Have you double checked `/tmp/corpsoDB.txt` file? – AnFi Sep 19 '20 at 13:01

0 Answers0