On 17.07.03,14:51, Keith Olmstead wrote:
> Hello,
> 
> Been searching though this list for awhile now, and now I am needing some help.  I 
> am not asking for someone to do my code for me,  I am trying to learn perl and the 
> only way for me to do that is to dive staight into it.
> 
> My problem is with the theory of the script that I am trying to write.  I am needing 
> something to backup logs for me from a central log server.  They layout of these 
> files are as follows.
> 
> /host/ip/year/month/day/log1, log2, etc
> 
> Every file and dir under dir1 is created dynamically by the logging program, 
> syslog-ng.
> 
> What I am wanting to do is create a script that will tar and gzip the day dirs at 
> the end of the day and remove the dir after it has been backed up.  After the month 
> is finished, I would like the same done for it.
> 
> Currently there are 20ish host dirs, one of each server that is logging to this box. 
>  There will be more and when they get pointed to this server, the ip dir will be 
> created for that host and each dir under that will also be created for the 
> corresponding date.  The logs need to be kept for 2-3 months, and then deleted.
> 
> I am needing help thinking this script out, maybe get ideas of how to set it up.  
> From reading using File::Find, might be useful.  
> 
> I was thinking about writing a script that runs in cron each night that tars and gzp 
> the log dirs.  Currently I have a script that is getting a list of the dir, but I 
> don't really know  where to go from there.  I need to get it to dive into the dir to 
> the day lvl and archive the previous days logs.
> 
> Here are 2 scripts that I have been playing with.  I don't even know if I am going 
> in the right direction.
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
>  
> my $dir = '/opt/log/hosts/';
>  
> opendir(DIR, $dir) or die "Cannot open Directory";
>  
> # read the dir contents into a list, and grep out the . and .. dir entries
> my @entries = grep (!/^\.\.?$/ , readdir (DIR));
> closedir(DIR);
> foreach (@entries)
> {
>   print "$_\n";
> }
> 
> and
> 
> #!/usr/bin/perl
>  
> use File::Find;
> use strict;
> use warnings;
> my $startdir = $ARGV[0];
> my @dirlist;
> find(
>     sub {
>         return if -d and /^\.\.?$/;
>         push @dirlist, $_ if -d;
>     }, $startdir);
>  
> #my $file_list = join '<BR>', @dirlist;
> my $file_list = @dirlist;
> print $file_list;
> 
> Like I said before, I am not asking for someone to do my work just some guidiance in 
> the right direction.
> 
> TIA,
> 
> Keith Olmstead
> 

Hi,

As often is the case with Perl it's a good thing to be inspired by 
others good work. Check this:

http://www.dienhart.com/software/PERL_Scripts/documentation/daboobak.shtml#

- Jostein

> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
Jostein Berntsen <[EMAIL PROTECTED]>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to