Someone has already mentioned checking that the file is not already a gzip file. I see you have a test for that, but your regular expression does not correctly test if the file name ends in '.gz', only if it contains '.gz'.

I suggest:

next if /\.gz$/;

Your test of the file age might be more readable if you use '-M' (see perldoc perlfunc).

As others suggest do some timing measurements. The fact that the directory has 90,000 files might slow down directory related operations, especially if it is network mounted. unlink and gzip could be affected by this as they perform directory updates.

If you comment out the gzip portion, how long does the unlinking take on these large directories.

Measure how long gzip takes with a typical file. Also, when running your script check the processes. Is there a single long running gzip? You should be able to come up with some rough order of magnitude figures (I assume you have examined typical directories and have an idea of the number and sizes of files).

Also consider whether these directories a overdue for cleanup. If so, the first run of your script may take a lot longer that future runs.


In reply to Re: system "gzip $full_name" is taking more time by wazat
in thread system "gzip $full_name" is taking more time by dushyant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.