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:
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 scriptuntil ($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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Unlink works in windows, not in Linux?
by eyepopslikeamosquito (Archbishop) on Dec 12, 2012 at 04:53 UTC | |
Re: Unlink works in windows, not in Linux?
by Athanasius (Archbishop) on Dec 12, 2012 at 04:03 UTC | |
Re: Unlink works in windows, not in Linux?
by rovf (Priest) on Dec 12, 2012 at 10:00 UTC | |
Re: Unlink works in windows, not in Linux?
by tobyink (Canon) on Dec 12, 2012 at 07:07 UTC | |
Re: Unlink works in windows, not in Linux?
by Anonymous Monk on Dec 12, 2012 at 17:05 UTC |
Back to
Seekers of Perl Wisdom