Loading ...
Sorry, an error occurred while loading the content.

how to count mail on queue

Expand Messages
  • Zbigniew Szalbot
    Hello, How can I check how many messages are on queue without listing them? Mailq does what I want but I get the list which I do not need. What kind of switch
    Message 1 of 12 , Mar 29, 2007
    • 0 Attachment
      Hello,

      How can I check how many messages are on queue without listing them? Mailq
      does what I want but I get the list which I do not need. What kind of
      switch can I use to get the number of emails on queue? I checked man
      postqueue and man mailq but can't seem to find it.

      Thank you!
      --
      Zbigniew Szalbot
    • Cami
      ... # mailq | tail -n 1 Cami
      Message 2 of 12 , Mar 30, 2007
      • 0 Attachment
        Zbigniew Szalbot wrote:
        > Hello,
        >
        > How can I check how many messages are on queue without listing them? Mailq
        > does what I want but I get the list which I do not need. What kind of
        > switch can I use to get the number of emails on queue? I checked man
        > postqueue and man mailq but can't seem to find it.

        # mailq | tail -n 1

        Cami
      • Zbigniew Szalbot
        Hello, ... Thank you very much. That s exactly what I was looking for! Warm regards, -- Zbigniew Szalbot
        Message 3 of 12 , Mar 30, 2007
        • 0 Attachment
          Hello,

          >> How can I check how many messages are on queue without listing them?
          >> Mailq
          >> does what I want but I get the list which I do not need. What kind of
          >> switch can I use to get the number of emails on queue? I checked man
          >> postqueue and man mailq but can't seem to find it.
          >
          > # mailq | tail -n 1

          Thank you very much. That's exactly what I was looking for!

          Warm regards,

          --
          Zbigniew Szalbot
        • Michael J Wise
          ... Or... sudo find /var/spool/postfix/deferred -type f -print | wc -l Aloha mai Nai`a! -- Please have your Internet License
          Message 4 of 12 , Mar 30, 2007
          • 0 Attachment
            On Mar 30, 2007, at 12:03 AM, Zbigniew Szalbot wrote:

            >>> How can I check how many messages are on queue without listing them?
            >>> Mailq
            >>> does what I want but I get the list which I do not need. What
            >>> kind of
            >>> switch can I use to get the number of emails on queue? I checked man
            >>> postqueue and man mailq but can't seem to find it.
            >>
            >> # mailq | tail -n 1
            >
            > Thank you very much. That's exactly what I was looking for!

            Or...

            sudo find /var/spool/postfix/deferred -type f -print | wc -l

            Aloha mai Nai`a!
            --
            "Please have your Internet License <http://kapu.net/~mjwise/>
            and Usenet Registration handy..."
          • Eric Frazier
            ... Question. This looks like it would be a lot nicer to the system than mailq since I would just guess you end up doing a couple of stats, instead of reading
            Message 5 of 12 , Mar 30, 2007
            • 0 Attachment
              On 30-Mar-07, at 9:29 AM, Michael J Wise wrote:

              > On Mar 30, 2007, at 12:03 AM, Zbigniew Szalbot wrote:
              >
              >>>> How can I check how many messages are on queue without listing
              >>>> them?
              >>>> Mailq
              >>>> does what I want but I get the list which I do not need. What
              >>>> kind of
              >>>> switch can I use to get the number of emails on queue? I checked
              >>>> man
              >>>> postqueue and man mailq but can't seem to find it.
              >>>
              >>> # mailq | tail -n 1
              >>
              >> Thank you very much. That's exactly what I was looking for!
              >
              > Or...
              >
              > sudo find /var/spool/postfix/deferred -type f -print | wc -l
              >

              Question. This looks like it would be a lot nicer to the system than
              mailq since I would just guess you end up doing a couple of stats,
              instead of reading out the status of every message. Is that the
              idea? But I wonder is there a reason a really good way of getting a
              que count isn't a part of the MTA? Like can't it keep a counter for
              itself that we could just read? Just curious, it isn't like it is
              that hard to count files, or db entries or whatever.



              > Aloha mai Nai`a!
              > --
              > "Please have your Internet License <http://kapu.net/
              > ~mjwise/>
              > and Usenet Registration handy..."
              >
              >
              >
            • Victor Duchovni
              ... This has to stat every file and so incurs a lot of I/O, by far faster on systems with leaf-directory optimization is: sudo find
              Message 6 of 12 , Mar 30, 2007
              • 0 Attachment
                On Fri, Mar 30, 2007 at 10:02:37AM -0700, Eric Frazier wrote:

                > > sudo find /var/spool/postfix/deferred -type f -print | wc -l

                This has to stat every file and so incurs a lot of I/O, by far faster on
                systems with leaf-directory optimization is:

                sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l

                > Question. This looks like it would be a lot nicer to the system than
                > mailq since I would just guess you end up doing a couple of stats,
                > instead of reading out the status of every message. Is that the
                > idea? But I wonder is there a reason a really good way of getting a
                > que count isn't a part of the MTA? Like can't it keep a counter for
                > itself that we could just read? Just curious, it isn't like it is
                > that hard to count files, or db entries or whatever.

                The Postfix queue manager does not track the state of files in the
                deferred queue, they can be moved around behind its back using postsuper.

                The find command above is sufficiently fast on most systems. Install
                and use gfind (GNU find from binutils) if the system find does not
                leaf-node optimize.

                --
                Viktor.

                Disclaimer: off-list followups get on-list replies or get ignored.
                Please do not ignore the "Reply-To" header.

                To unsubscribe from the postfix-users list, visit
                http://www.postfix.org/lists.html or click the link below:
                <mailto:majordomo@...?body=unsubscribe%20postfix-users>

                If my response solves your problem, the best way to thank me is to not
                send an "it worked, thanks" follow-up. If you must respond, please put
                "It worked, thanks" in the "Subject" so I can delete these quickly.
              • Anthony J. Biacco
                How about a shell script with something like: my_qdir=`/usr/sbin/postconf -h queue_directory` my_active=`find $my_qdir/incoming $my_qdir/active
                Message 7 of 12 , Mar 30, 2007
                • 0 Attachment
                  How about a shell script with something like:

                  my_qdir=`/usr/sbin/postconf -h queue_directory`
                  my_active=`find $my_qdir/incoming $my_qdir/active $my_qdir/maildrop -type f
                  -print | wc -l | awk '{print $1}'`
                  my_deferred=`find $my_qdir/deferred -type f -print | wc -l | awk '{print
                  $1}'`

                  echo ACTIVE MSG COUNT: $my_active
                  echo DEFERRED MSG COUNT: $my_deferred


                  --
                  Anthony J. Biacco
                  Senior Systems and Network Administrator
                  303-981-4955

                  -----Original Message-----
                  From: owner-postfix-users@...
                  [mailto:owner-postfix-users@...] On Behalf Of Zbigniew Szalbot
                  Sent: Friday, March 30, 2007 12:44 AM
                  To: postfix-users@...
                  Subject: how to count mail on queue

                  Hello,

                  How can I check how many messages are on queue without listing them? Mailq
                  does what I want but I get the list which I do not need. What kind of
                  switch can I use to get the number of emails on queue? I checked man
                  postqueue and man mailq but can't seem to find it.

                  Thank you!
                  --
                  Zbigniew Szalbot
                • Julian Cowley
                  ... That s pretty nice. Unless I m missing something, looks like it can be further reduced to: sudo find /var/spool/postfix/deferred/. ! -name ? -print | wc
                  Message 8 of 12 , Apr 1, 2007
                  • 0 Attachment
                    On Fri, 30 Mar 2007, Victor Duchovni wrote:
                    > On Fri, Mar 30, 2007 at 10:02:37AM -0700, Eric Frazier wrote:
                    >
                    > > > sudo find /var/spool/postfix/deferred -type f -print | wc -l
                    >
                    > This has to stat every file and so incurs a lot of I/O, by far faster on
                    > systems with leaf-directory optimization is:
                    >
                    > sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l

                    That's pretty nice. Unless I'm missing something, looks like it can
                    be further reduced to:

                    sudo find /var/spool/postfix/deferred/. ! -name '?' -print | wc -l

                    At least it works on my system. YMMV.

                    We have a script at work that does something similar to this (which
                    also depends on leaf-directory optimization). It gets around doing
                    stat() by listing the queue directories directly on the command
                    line, but it then has to subtract the directory count to get the
                    right answer. I like Victor's version much better since it is simple
                    and elegant.
                  • Victor Duchovni
                    ... Provided you are willing to subtract 1 at the end, yes. -- Viktor. Disclaimer: off-list followups get on-list replies or get ignored. Please do not ignore
                    Message 9 of 12 , Apr 1, 2007
                    • 0 Attachment
                      On Sat, Mar 31, 2007 at 10:12:30PM -1000, Julian Cowley wrote:

                      > On Fri, 30 Mar 2007, Victor Duchovni wrote:
                      > > On Fri, Mar 30, 2007 at 10:02:37AM -0700, Eric Frazier wrote:
                      > >
                      > > > > sudo find /var/spool/postfix/deferred -type f -print | wc -l
                      > >
                      > > This has to stat every file and so incurs a lot of I/O, by far faster on
                      > > systems with leaf-directory optimization is:
                      > >
                      > > sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l
                      >
                      > That's pretty nice. Unless I'm missing something, looks like it can
                      > be further reduced to:
                      >
                      > sudo find /var/spool/postfix/deferred/. ! -name '?' -print | wc -l
                      >

                      Provided you are willing to subtract 1 at the end, yes.

                      --
                      Viktor.

                      Disclaimer: off-list followups get on-list replies or get ignored.
                      Please do not ignore the "Reply-To" header.

                      To unsubscribe from the postfix-users list, visit
                      http://www.postfix.org/lists.html or click the link below:
                      <mailto:majordomo@...?body=unsubscribe%20postfix-users>

                      If my response solves your problem, the best way to thank me is to not
                      send an "it worked, thanks" follow-up. If you must respond, please put
                      "It worked, thanks" in the "Subject" so I can delete these quickly.
                    • Miles Fidelman
                      ... I use: /usr/bin/mailq |grep Requests Miles
                      Message 10 of 12 , Apr 1, 2007
                      • 0 Attachment
                        Victor Duchovni wrote:
                        > On Sat, Mar 31, 2007 at 10:12:30PM -1000, Julian Cowley wrote:
                        >
                        >
                        >> On Fri, 30 Mar 2007, Victor Duchovni wrote:
                        >>
                        >>> On Fri, Mar 30, 2007 at 10:02:37AM -0700, Eric Frazier wrote:
                        >>>
                        >>>
                        >>>>> sudo find /var/spool/postfix/deferred -type f -print | wc -l
                        >>>>>
                        >>> This has to stat every file and so incurs a lot of I/O, by far faster on
                        >>> systems with leaf-directory optimization is:
                        >>>
                        >>> sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l
                        >>>
                        >> That's pretty nice. Unless I'm missing something, looks like it can
                        >> be further reduced to:
                        >>
                        >> sudo find /var/spool/postfix/deferred/. ! -name '?' -print | wc -l
                        >>
                        >>
                        >
                        > Provided you are willing to subtract 1 at the end, yes.
                        >
                        >
                        I use:
                        /usr/bin/mailq |grep Requests

                        Miles
                      • Julian Cowley
                        ... I knew there was a catch. I ve found that with the GNU version of find, ? doesn t match . at the beginning of a filename, whereas on FreeBSD it does.
                        Message 11 of 12 , Apr 1, 2007
                        • 0 Attachment
                          On Sun, 1 Apr 2007, Victor Duchovni wrote:
                          > On Sat, Mar 31, 2007 at 10:12:30PM -1000, Julian Cowley wrote:
                          > > On Fri, 30 Mar 2007, Victor Duchovni wrote:
                          > > > On Fri, Mar 30, 2007 at 10:02:37AM -0700, Eric Frazier wrote:
                          > > >
                          > > > > > sudo find /var/spool/postfix/deferred -type f -print | wc -l
                          > > >
                          > > > This has to stat every file and so incurs a lot of I/O, by far faster on
                          > > > systems with leaf-directory optimization is:
                          > > >
                          > > > sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l
                          > >
                          > > That's pretty nice. Unless I'm missing something, looks like it can
                          > > be further reduced to:
                          > >
                          > > sudo find /var/spool/postfix/deferred/. ! -name '?' -print | wc -l
                          >
                          > Provided you are willing to subtract 1 at the end, yes.

                          I knew there was a catch. I've found that with the GNU version
                          of find, '?' doesn't match '.' at the beginning of a filename,
                          whereas on FreeBSD it does. Still, the original version works on
                          both operating systems.
                        • Chuck Amadi
                          ... Very simple line of:: mailq | tail -1 Cheers -- Chuck Amadi ROK Corporation Limited Ty ROK, Dyffryn Business Park, Llantwit Major Road, Llandow, Vale Of
                          Message 12 of 12 , Apr 2, 2007
                          • 0 Attachment
                            Victor Duchovni wrote:
                            > On Sat, Mar 31, 2007 at 10:12:30PM -1000, Julian Cowley wrote:
                            >
                            >
                            >> On Fri, 30 Mar 2007, Victor Duchovni wrote:
                            >>
                            >>> On Fri, Mar 30, 2007 at 10:02:37AM -0700, Eric Frazier wrote:
                            >>>
                            >>>
                            >>>>> sudo find /var/spool/postfix/deferred -type f -print | wc -l
                            >>>>>
                            >>> This has to stat every file and so incurs a lot of I/O, by far faster on
                            >>> systems with leaf-directory optimization is:
                            >>>
                            >>> sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l
                            >>>
                            >> That's pretty nice. Unless I'm missing something, looks like it can
                            >> be further reduced to:
                            >>
                            >> sudo find /var/spool/postfix/deferred/. ! -name '?' -print | wc -l
                            >>
                            >>
                            >
                            > Provided you are willing to subtract 1 at the end, yes.
                            >
                            >
                            Very simple line of::

                            mailq | tail -1

                            Cheers

                            --
                            Chuck Amadi
                            ROK Corporation Limited
                            Ty ROK,
                            Dyffryn Business Park,
                            Llantwit Major Road,
                            Llandow,
                            Vale Of Glamorgan.
                            CF71 7PY

                            Tel: 01446 795 839
                            Fax: 01446 794 994
                            International Tel: +44 1446 795 839

                            email: chuck.amadi@...

                            This email is confidential to the addressee only. If you do not believe
                            that you are the intended recipient, do not pass it on or copy it in any
                            way. Please delete it immediately.
                          Your message has been successfully submitted and would be delivered to recipients shortly.