Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How can I get number of messages count in Postfix's mailq? mailq command display entire mails in mailq but i would like to know count only.Is there any command for this. My OS is centos 5.5.

share|improve this question

3 Answers 3

up vote 6 down vote accepted

I use this:

mailq | grep -c "^[A-Z0-9]"

You can pipe the output of mailq through various other filters such as uniq, sort and wc to get other statistics.

share|improve this answer
This is not accurate. When the Postfix queue is empty, then run 'mailq', we will get "Mail queue is empty" which also match "^[0-9A-Z]". And in such a situation it is not accurate. –  andy Jul 7 at 12:59

either mailq | tail -n 1 or find /var/spool/postfix/deferred -type f | wc -l

both works

share|improve this answer

Pipe the ouput to wc, if further refining is required, use grep.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.