in reply to Random script crashes related to File::Copy

As others have mentioned above, this may be because the file has not yet finished writing. I would use a "stable" file concept and check that the file has not been modified since X time period.
# check if the file has stablized for over 30 seconds if (is_stable_file($file, 30)) { process($file); } sub is_stable_file { my $file = shift; my $wait_seconds = shift || 0; my $result = 1; if ($wait_seconds > 0) { my ($mtime) = (stat($file))[9]; my $secs_since_mod = (time - $mtime); if ($secs_since_mod < $wait_seconds) { $result = 0; } } return $result; }