Help us understand the problem. What is going on with this article?

maillogから、送信においてなんらかのエラーが発生したログをgrepするコマンド

More than 1 year has passed since last update.
less /var/log/maillog |grep -v 'dsn=2\.0\.0'  | grep 'dsn=' 

SMTPは、正常な送信を行うとdsn=2.0.0を返しますので、それをgrep -vで除外してやると、なんらかのエラーが起こったあたりを抜き出すことができるのではないか。

dsnについては以下参照。httpのステータスコードみたいなもの
https://oxynotes.com/?p=9810

less /var/log/maillog |grep -v 'dsn=2\.0\.0' | grep 'dsn=' -A 4

のようにすれば、その行だけでなく、該当した後の数行(この場合は4行)も見れてみやすい

ちなみに、とりあえず送信できていないやつだけgrepしたい場合(エラーが出てても、送信済みなら問題ないとする場合)は、status=sentの方をgrepしてやると見やすいと思う。

less /var/log/maillog | grep -v 'status=sent' | grep 'status=' -A 4

みたいな感じで。

なにはともあれ、-v オプションと -Aオプションは便利。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away