mnlight has asked for the wisdom of the Perl Monks concerning the following question:
sub clean_up() { my ( $mtime ) = ( stat $_ )[9]; my $BACKUP_TIME = $params->get("Backup.Tape.Start"); my $SERVER = $params->get("Backup.Server"); my $SAVE_DAYS = 1; my $SAVE_DAYS = $params->get("Backup.Save.Days") if ( $params->exists( +"Backup.Save.Days") ); my ( $BACKUP_HOUR, $BACKUP_MIN ); if ( $BACKUP_TIME =~ /^\d{1,2}:\d{1,2}$/ ) { ( $BACKUP_HOUR, $BACKUP_MIN ) = split /:/, $BACKUP_TIME; } else { $app->log($WARN, "Parameter \"Backup.Tape.Start\" not formatted pr +operly [ HH:MM ]. Defaulting to 07:00"); ( $BACKUP_HOUR, $BACKUP_MIN ) = ( 07, 00 ); } my ($min, $hour, $mday, $month, $year ) = (localtime)[1,2,3,4,5]; my $time = timelocal(0,$BACKUP_MIN,$BACKUP_HOUR,$mday,$month,$year); ##Set time to yesterday if current time of day < configured back-up t +ime $time -= ((60 * 60) * (24 * $SAVE_DAYS)) if ( $hour < $BACKUP_HOUR || ( $hour == $BACKUP_HOUR && $min < $BA +CKUP_MIN )); if ( $mtime < $time ){ print "$_\n"; } #unlink $_ if ( $mtime < $time ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Setting timelocal back by days
by shmem (Chancellor) on Sep 15, 2007 at 10:22 UTC | |
by mnlight (Scribe) on Sep 17, 2007 at 15:48 UTC |