Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
######################################################## # Moving files from one location to # another, creating folder based on local time stamped # # (did not do yet: zipped logs up based on time stamp and # put in the folder.) ######################################################## my $filedir = "\\\\TESTSERVER01\\Weblogiclogs\\"; my $IWlogs = "\\\\TESTServer01\\Weblogiclogs\\*.log*"; # get timestamp to name a file yymmddhhmiss.txt ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $mon = (1,2,3,4,5,6,7,8,9,10,11,12)[$mon]; if($mon < 10){$mon = "0" . $mon;} # add a leading zero to one- +digit months if($mday < 10){$mday = "0" . $mday;} # add a leading zero to one-di +git days if($hour < 10){$hour = "0" . $hour;} # add a leading zero to one-di +git hours if($min < 10){$min = "0" . $min;} # add a leading zero to one- +digit minutes if($sec < 10){$sec = "0" . $sec;} # add a leading zero to one +-digit seconds $dirname = substr($year,1,3) . $mon . $mday . $hour . $min . $sec; $createDir = $filedir . "\\" . $dirname; if(!-e $createDir) { @args = ( "mkdir", $createDir); system(@args) == 0 or die "error creating $createDir!"; } # move log files to new directory @args = ( "move" , $IWlogs , $createDir ) ; system( @args ) == 0 or die "error moving $IWlogs!";
Edit: Added <code> and <ol> tags. larsen
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moving log files, create folder based on local time/date & zip them up based on local time & date.
by mjeaton (Hermit) on Sep 09, 2002 at 18:55 UTC | |
by Anonymous Monk on Sep 09, 2002 at 19:13 UTC | |
by charnos (Friar) on Sep 09, 2002 at 19:32 UTC | |
by mjeaton (Hermit) on Sep 09, 2002 at 19:31 UTC | |
|
Re: Moving log files, create folder based on local time/date & zip them up based on local time & date.
by charnos (Friar) on Sep 09, 2002 at 19:11 UTC | |
|
Re: Moving log files, create folder based on local time/date & zip them up based on local time & date.
by grinder (Bishop) on Sep 09, 2002 at 20:29 UTC |