http://qs321.pair.com?node_id=1008432

jagexCoder has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have a server that creates log files of with certain file names, I'm use regex to detect these filenames and based on them delete the logs that are older than 24 hours. The script works great tested on Windows XP, however in Linux it does not work. The backup files are not deleted and the log does not mention any files were deleted. Also the $unlink does not display the warning message. Here's the relevant part of the code:
until ($log_written != 0) { print FILE "*** SCRIPT RUN ON: " . $dt . " ***\n"; print FILE "Deleting backup files more than 1 day old:\n"; foreach my $file (<grm_backup-*_*_*_*_*_*_EST_*.bak>) { if ( -M $file > 2 ) { #print "Deleting the log file more than 1 days old: " . $f +ile; unlink $file or die "\nCould not delete the backup $file: +$!"; print FILE "Deleted -> " . $file . "\n"; } } foreach my $file2 (<backup_db-*_*_*_*_*_*_EST_*.bak>){ if ( -M $file2 > 2 ) { #print "Deleting the log file more than 1 days old: " . $f +ile2; unlink $file2 or die "\nCould not delete the backup $file2 +: $!"; print FILE "Deleted -> " . $file2 . "\n"; } } print FILE "\n\n"; print "Backups older than 1 day have been successfully deleted! Se +e LOG file for more details.\n"; $log_written = 1; }
All advice appreciated thanks EDIT: I should mention that unlink works if I type in: "unlink cmc_rules-Mon_Dec_12_12_31_01_EST_2012" Just not via the script