Getting the size of the mail queue. 
Author Message
 Getting the size of the mail queue.

[Posted and emailed -- followups set to comp.unix.questions.]

Quote:

>We have the need occasionally to count files in very, very
>large directories, such as the incoming news spool on a
>system which hasn't been unbatching for 48 hours or more.
>Doing an ls | wc takes a great deal of time, since the ls
>does stupid things like sorting the entries in the interim.

Not necessarily--use GNU ls:

       -f     Do  not sort directory contents; list them in what-
              ever order they are stored on the disk.   The  same
              as enabling -a and -U and disabling -l, -s, and -t.

-Peter

--

--



Mon, 10 Nov 1997 03:00:00 GMT  
 Getting the size of the mail queue.


Quote:
>Ooops... ignore my last message.  You don't want the size of the file, you
>want the size of the queue... one way to do it is:

>> ls -l /var/spool/mqueue/qf* | wc -l
>    17

>17

We have the need occasionally to count files in very, very
large directories, such as the incoming news spool on a
system which hasn't been unbatching for 48 hours or more.
Doing an ls | wc takes a great deal of time, since the ls
does stupid things like sorting the entries in the interim.
Since, by my reading of the perl5 man pages, the globbing
functions are still implemented by spawning an echo process,
this may suffer from the same problem.

It seems to me that a reasonably fast way to do it would be
to do an opendir on the offending directory and iterate over
readdir, counting entries along the way.  I haven't tried
this, however, and don't presently have enough data to do a
decent benchmark.  At any rate I defer to the experts on
whether or not this would be a faster or better solution
than globbing the directory.

--
By sending unsolicited commercially-oriented e-mail to this address, the
sender agrees to pay a $100 flat fee to the recipient for proofreading
services.



Mon, 10 Nov 1997 03:00:00 GMT  
 Getting the size of the mail queue.
|> Doing an ls | wc takes a great deal of time, since the ls
|> does stupid things like sorting the entries in the interim.

I can't speak to the Perl aspects of this, but from the Unix
perspecive, try "ls -f | wc".  The "-f" option keeps "ls" from
doing all the sorting, and what's likely worse, stat'ing (as is
often caused when folks have an alias for "ls" that asks for such
things as marking executables, subdirectories and symlinks.)

--

                                I won't rest till it's the best ...
                                Software Production Engineer



Mon, 10 Nov 1997 03:00:00 GMT  
 Getting the size of the mail queue.
In comp.lang.perl.misc,



:
:>Ooops... ignore my last message.  You don't want the size of the file, you
:>want the size of the queue... one way to do it is:
:>
:>> ls -l /var/spool/mqueue/qf* | wc -l
:>    17

:>17
:
:We have the need occasionally to count files in very, very
:large directories, such as the incoming news spool on a
:system which hasn't been unbatching for 48 hours or more.
:Doing an ls | wc takes a great deal of time, since the ls
:does stupid things like sorting the entries in the interim.
:Since, by my reading of the perl5 man pages, the globbing
:functions are still implemented by spawning an echo process,
:this may suffer from the same problem.
:
:It seems to me that a reasonably fast way to do it would be
:to do an opendir on the offending directory and iterate over
:readdir, counting entries along the way.  I haven't tried
:this, however, and don't presently have enough data to do a
:decent benchmark.  At any rate I defer to the experts on
:whether or not this would be a faster or better solution
:than globbing the directory.

The only safe way is with opendir.  If you have csh, globs will
blow up.  If you don't have csh, globs will use sh and run faster
but not work on spaces in filenames.  If you install tcsh *IN*
/bin/csh, globs will actually work quite well, but somewhat
more that a simple echo * out of sh.  

--tom
--

There are two ways to write error-free programs.  Only the third one
works.



Tue, 11 Nov 1997 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. NET::SMTP Mail not sent- Queued mail for delivery

2. Socket Q: Minimum listen queue size

3. IO::Socket - Listen queue size

4. Socket Q: Minimum listen queue size

5. perl script to list sender,recipient,subject in mail queue

6. Need example code that can read a mail queue

7. NET::SMTP email not sent -Queued mail for delivery

8. getting mail header from entering mail

9. CGI.pm Bug: file upload file size mismatch when file size is close to buffer size

10. Getting Traffic Size in Bytes from W3C Extended Format Log

11. Getting partition size from perl script

12. Getting NTFS Directory structure size

 

 
Powered by phpBB® Forum Software