電子メールでログファイルを送信できるスクリプトを作成したいと思います。これで問題は、電子メールで受信したテキストファイルが空であることです。どの部分が問題ですか?
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="[email protected]"
(
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
/tmp/corpsoDB.txt
/usr/sbin/mysqld, Version: 5.7.31-log (MySQL Community Server (GPL)). started w$
Tcp port: 0 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
ティー/tmp/sendmail-input.txt
Subject: MySQL Slow Query Log Report-Corpso
Content-Type: multipart/mixed; boundary="-omgemailslikewhoa"
---omgemailslikewhoa
Content-Type: text/plain
Content-Disposition: inline
GET ON IT.
---omgemailslikewhoa
Content-Type: text/plain; name="corpsoDB.txt"
Content-Disposition: attachment; filename="corpsoDB.txt"
/usr/sbin/mysqld, Version: 5.7.31-log (MySQL Community Server (GPL)). started w$
Tcp port: 0 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
---omgemailslikewhoa--
私は電子メールで受け取ったものです。 https://drive.google.com/file/d/1jnNuezyWxYAdNW_ZZ9ZvG1MG3ZJFLaBc/view?usp=sharing
ベストアンサー1
コンテンツ処理:ファイル名="corpsoDB.txt" 終わり 猫/tmp/corpsoDB.txt
本文セクションのタイトルと本文セクションの内容の間に改行を生成する必要があります。