truncate STDOUT, 0; #clear out STDOUT to start with a fresh log file. chdir $local_dir or die "Cannot change to $local_dir. $!";