Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Unlink works in windows, not in Linux? by jagexCoder

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2018-05-26 10:30 GMT
    Find Nodes?
      Voting Booth?