Is there a simple command to find out the current number of messages in the linux mail queue? mailq dumps out a verbose list, but it's not convenient for a quick overview.
As a related matter, you can also obtain the number of messages in your mailbox stored in mbox format, by modifying Brian Showalter's suggestion using the command "mail --headers." For example, I have this line in my .bashrc file:
if [ -s /var/mail/$(whoami) ] ; then echo -e "\nYou have $(ls -s -h /var/mail/$(whoami) | cut -d" " -f 1) of mail. Number of messages: $(mail --file /var/mail/$(whoami) --headers | wc -l) ($(mail --file /var/mail/$(whoami) --headers | sed '/^>* *[0-9]/d' | wc -l) unread)" ; fi
If you just want to know the number of messages sitting in the deferred queue, then the following should get you a quick answer:
There are three other queues. See http://www.porcupine.org/postfix/queueing.html for details.
You could filter the output and display only the last line:
As a related matter, you can also obtain the number of messages in your mailbox stored in mbox format, by modifying Brian Showalter's suggestion using the command "mail --headers." For example, I have this line in my .bashrc file:
This is
good idea, but it doesn't work if my Zabbix-Agent isn't run as a root. So I used this
for my own UserParameter.