I run an Apache Web server with many Virtual Hosts. The numbers of Virtual Hosts is increasing and I would like to streamline our administration of server logs. I would like to cron two jobs, weekly and monthly, to gzip and mail log files to the owners of the sites. Using find2perl /home/www/*/logs/weekly and find2perl /home/www/*/logs/monthly I can generate Perl code to search for files named weekly and monthly. Here's an example:
#! /usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' f 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::Find::dont_use_nlink if you're using AFS, + # since AFS cheats. # for the convenience of &wanted calls, including -eval statements: + use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; # Traverse desired filesystems File::Find::find({wanted => \&wanted}, '/home/www/admin/logs/weekly', +'/home/www/nsms/logs/weekly'); exit; sub wanted { ; }
My plan is then to add some code to the wanted sub-routine which will gzip the logs held in /home/www/*/logs and mail it to site owners. Now to my problem. The number of virtual hosts changes from week to week. I would like to totally automate this process using Perl. I need to run the find2perl command to get a complete lsiting of all the relevant directories but when I run this it creates new code each time with a correct directory listing but with an empty "wanted" sub-routine. Is it possible to run my find2perl command and add the Perl code I want to use to gzip and mail the logs to the "wanted" sub-routine at the same time?

In reply to Searching a directory tree by wylie

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.