场景:生产环境的日志文件中有错误信息时,想通过邮件将错误内容发送给管理者。
#!/bin/bash
monitor=/product/log/file/path
content=/this/program/log/file
tail -5 $monfile|grep fail >$content
if [ -s $content ];then
mail -s "mail title" -c xxx@xxx.com <$content
fi
#!/bin/bash
monitor=/product/log/file/path
content=/this/program/log/file
tail -5 $monfile|grep fail >$content
if [ -s $content ];then
mail -s "mail title" -c xxx@xxx.com <$content
fi