in reply to Re^3: how to log a process
in thread how to log a process
I know you had some ...more sophisicated ways of dealing with the time... I fell back on what I understood. ( grin ) I suppose I *could be premature with the happy dance -- but. It sure looks good. well, the odds look good. I am sure the code looks clumsy to you. How about that double var for current time $now & $now2 ( i am to happy to be ashamed -- refinement will come) all the thanks to you here is a question ? do i need to Close the log at the end?###:WAS Oven1 = '/media/oven_web/iportal/uploads' # rvsd to oven2 - 4-2009 js # /oven_web/iportal/uploads # # to del files older than 30 days ### 2.28.2008 - js #!/usr/local/bin/perl # 2592000 = 30 day n min (60 *60 * 24 *30 ) use strict; # change the below to dlt - my $dir = '/oven_web/iportal/cgi-bin/uploads2'; my $now2 = localtime time; my $logfile = "/oven_script/script_logs/30DayDlt-LOG.txt"; open (LOGFILE, ">>$logfile") or die "Cannot open logfile $logfile for +append $!"; opendir(DIR,$dir) || die "Can't open $dir : $!\n"; my @files = readdir(DIR); # you may want to grep only certain files he +re close(DIR); print LOGFILE "$now2 \n"; foreach my $file(@files) { my $now = time; my @stat = stat("$dir/$file"); if ($stat[9] < ($now - 2592000)) { print "Deleting $dir/$file..."; #unlink("$dir/$file"); #print "Done.\n"; print LOGFILE "$dir/$file deleted\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: how to log a process
by Marshall (Canon) on May 29, 2009 at 00:10 UTC | |
by zimbot (Initiate) on Jun 01, 2009 at 13:12 UTC | |
by Marshall (Canon) on Jun 01, 2009 at 18:31 UTC |