automation, monitoring, scripting, Uncategorized

How to send attachment from Linux

There are some cases when its needed to send via email many scripts output results from Linux command line.  Here is an working example to achieve this.

It is expected that email options have been already configured so that mail command is working.

Below is the example of command which will zip all related logs  from /tmp folder into a .zip file “WLCs_logs.zip”

zip -r /tmp/WLCs_logs.zip /tmp/WLCs-peers-*.log.filtered

next command will send email with .zip attachment to me@mymail.com

mpack -s “AVC and other data from WLCs” /tmp/WLCs_logs.zip me@mymail.com

Mentioned commands can be executed from cron on a regular basis.