in reply to Re: how to log a process
in thread how to log a process
that blew up with /usr/bin/perl /oven_script/tst/dlt30day-oven1d-j3.pl Global symbol "$file" requires explicit package name at /oven_script/tst/dlt30day-oven1d-j3.pl line 16. Execution of /oven_script/tst/dlt30day-oven1d-j3.pl aborted due to compilation errors. But -- thanks!#!/usr/local/bin/perl # 2592000 = 30 day n min (60 *60 * 24 *30 ) use strict; use POSIX; use warnings; # change the below to dlt - dl30 my $logfile = "/script_logs/30DyDlt-LOG.txt"; my $date = localtime(); my $dir = '/oven_web/iportal/cgi-bin/uploads'; opendir(DIR,$dir) || die "Can't open $dir : $!\n"; #my @files = readdir(DIR); # you may want to grep only certain files h +ere my @files = grep{-f "$dir/$_"} readdir(DIR); close(DIR); ### my $logmsg = $date/$dir/$file; my $logmsg = "$date/$dir/$file"; #print $logmsg = $date/$dir/$file; open LOGFILE, ">> $logmsg " or die " cannot open logfie $logfile for a +ppend $!"; 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 "$logmsg \n"; } } close LOGFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to log a process
by Marshall (Canon) on May 28, 2009 at 14:50 UTC | |
by zimbot (Initiate) on May 28, 2009 at 23:36 UTC | |
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 |