我在本地使用 Postfix。我正在编写一个脚本来获取每天的延迟/退回邮件报告。如果我是正确的,通常日志会像日志文件中的列一样打印。
我的建议是我想grep前一天的“to”,“status”,“said”,它的消息例如“said:550 Invalid Recipient”。事情是相同的日志被打印了几次,但我需要grep 所有类似日志中的任何一个。
2 月 13 日 13:40:35 ganga11 postfix/smtp[12098]: 3371F2BF52: to=, relay=none, delay=1.2, delays=0.84/0.01/0.27/0.07, dsn=5.1.1, status=bounced (主持人说: 550 5.1.1 Recipient not found. http://x.co/irbounce (回复 RCPT TO 命令))
2 月 13 日 13:40:35 ganga11 postfix/smtp[6923]: 3371F2BF52: to=, relay=none, delay=1.5, delays=0.84/0/0.46/0.19, dsn=5.0.0, status=bounced (主持人说: 550 没有这样的用户 (grace@mmn.com (回复 RCPT TO 命令))
2 月 13 日 13:40:35 ganga11 postfix/smtp[29489]: 3371F2BF52: to=, relay=none, delay=1.3, delays=0.84/0.01/0.38/0.1, dsn=5.0.0, status=bounced (主持人说: 550 #5.1.0 地址被拒绝。(回复 RCPT TO 命令))
Feb 13 08:14:45 ganga11 postfix/smtp[6736]: F093B2BCA3: to=, relay=none, delay=6139, delays=6139/0.02/0.15/0, dsn=4.4.1, status=deferred (connect to aaaaaa.co.in 连接被拒绝)
2 月 13 日 13:40:36 ganga11 postfix/smtp[6940]: 3371F2BF52: to=, relay=none, delay=2.3, delays=0.84/0.01/0.17/1.3, dsn=5.1.1, status=bounced (主持人说: 550 5.1.1 Recipient not found. http://x.co/irbounce (回复 RCPT TO 命令))
2 月 13 日 13:40:35 ganga11 postfix/smtp[6923]: 3371F2BF52: to=, relay=none, delay=1.5, delays=0.84/0/0.46/0.23, dsn=5.0.0, status=bounced (主持人说: 550 没有这样的用户 (raj@yahoo.in) (回复 RCPT TO 命令))
Feb 13 04:14:24 ganga11 postfix/smtp[6736]: F093B2BCA3: to=, relay=none, delay=6139, delays=6139/0.02/0.15/0, dsn=4.4.1, status=deferred (connect to xyzz.com 连接被拒绝)
2 月 13 日 17:14:11 ganga11 postfix/smtp[6736]: F093B2BCA3: to=, relay=none, delay=6139, delays=6139/0.02/0.15/0, dsn=4.4.1, status=deferred (connect to bbbbb.com 连接被拒绝)