好吧,我有一個文件夾中有650萬個圖像,我需要讓他們儘快移動。我將把它們移到他們自己的文件夾結構中,但首先我必須讓它們從這個服務器上移開。「複製失敗:文件太大」perl錯誤
我試過rsync和cp以及各種其他工具,但它們總是最終出錯。所以我寫了一個perl腳本以更直接的方式提取信息。使用opendir並計算所有文件的工作是完美的。它可以在大約10秒鐘內對它們進行計數。現在,我嘗試將腳本向上移動一步,並實際移動文件,然後出現「文件太大」錯誤。這一定是某種錯誤的錯誤,因爲這些文件本身都很小。
#!/usr/bin/perl
#############################################
# CopyFilesLite
# Russell Perkins
# 7/12/2010
#
# Tool is used to copy millions of files
# while using as little memory as possible.
#############################################
use strict;
use warnings;
use File::Copy;
#dir1, dir2 passed from command line
my $dir1 = shift;
my $dir2 = shift;
#Varibles to keep count of things
my $count = 0;
my $cnt_FileExsists = 0;
my $cnt_FileCopied = 0;
#simple error checking and validation
die "Usage: $0 directory1 directory2\n" unless defined $dir2;
die "Not a directory: $dir1\n" unless -d $dir1;
die "Not a directory: $dir2\n" unless -d $dir2;
opendir DIR, "$dir1" or die "Could not open $dir1: $!\n";
while (my $file = readdir DIR){
if (-e $dir2 .'/' . $file){
#print $file . " exsists in " . $dir2 . "\n"; #debuging
$cnt_FileExsists++;
}else{
copy($dir1 . '/' . $file,$dir2 . '/' . $file) or die "Copy failed: $!";
$cnt_FileCopied++;
#print $file . " does not exsists in " . $dir2 . "\n"; #debuging
}
$count++;
}
closedir DIR;
#ToDo: Clean up output.
print "Total files: $count\nFiles not copied: $cnt_FileExsists\nFiles Copied: $cnt_FileCopied\n\n";
那麼你有沒有碰到過這個?什麼會導致這種情況,以及如何解決這個問題?
nfs對可以在目錄中的最大文件有一個硬限制。 – 2010-07-15 19:24:37