version 1.2, 2006/05/13 01:35:44
|
version 1.3, 2006/05/18 02:17:30
|
Line 27
|
Line 27
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
################################################# |
################################################# |
|
use Fcntl qw(:flock); |
|
|
my $oldfile="/home/httpd/perl/tmp/old_files.lst"; |
my $oldfile="/home/httpd/perl/tmp/old_files.lst"; |
system ("find /home/httpd/lonUsers/ -name *.db -atime +120 > $oldfile"); |
system ("find /home/httpd/lonUsers/ -name *.db -atime +120 > $oldfile"); |
Line 34 system ("find /home/httpd/lonUsers/ -nam
|
Line 35 system ("find /home/httpd/lonUsers/ -nam
|
open(IN,$oldfile); |
open(IN,$oldfile); |
while (my $dbfile=<IN>) { |
while (my $dbfile=<IN>) { |
chomp($dbfile); |
chomp($dbfile); |
if (-e "$dbfile.lock") { next; } |
my $sym; |
open(TOUCH,">>$dbfile.lock"); |
open($sym,">>$dbfile.lock"); |
close(TOUCH); |
unless (flock($sym,(LOCK_EX|LOCK_NB))) { |
|
close($sym); |
|
next; |
|
} |
system("gzip $dbfile"); |
system("gzip $dbfile"); |
my $histfile=$dbfile; |
my $histfile=$dbfile; |
$histfile=~s/\.db$/\.hist/; |
$histfile=~s/\.db$/\.hist/; |
if (-e $histfile) { |
if (-e $histfile) { |
system("gzip $histfile"); |
system("gzip $histfile"); |
} |
} |
unlink("$dbfile.lock"); |
flock($sym,LOCK_UN); |
|
close($sym); |
} |
} |
close(IN); |
close(IN); |
unlink($oldfile); |
unlink($oldfile); |