简体   繁体   中英

Include Log file content in mailx body

Below script sends mail and is working. How can I include the contents of a log file present inside /var/backup/log inside this?

echo "Below are the files copied during RUN" | mailx -v \

-r "network@testserver.com" \

-s "Backup Summary" \

-S smtp="smtp.testserver.com:25" \

me@myhome.com

Perhaps something like this : (EDITED to remove non-printable char)

(echo "Below are the files copied during RUN" && echo -e "\n----- somelogfile -----\n" && cat /var/backup/log/somelogfile) | tr -dc '[[:print:]]' | mailx -v \
-r "network@testserver.com" \
-s "Backup Summary" \
-S smtp="smtp.testserver.com:25" \
me@myhome.com

That solution will append the content of your log file in the mail body (the second "echo" is only there to add a reference in the mail)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM