Now I updated my code and it works! :) Thanks! I found another way to delete files that are older than x days, however, something strange came up... I don't know why it happened, but if I use the second delete section like this:

#### #### Check for expired backups #### print $backup_daily_subdir."\n"; die unless chdir "$backup_daily_subdir"; die unless opendir DIR, "."; foreach $file (grep {-f && (31 < -M)} readdir DIR) { unlink $file; } closedir DIR; print $backup_weekly_subdir."\n"; die unless chdir "$backup_weekly_subdir"; die unless opendir DR, "."; foreach $files (grep {-f && (365 < -M)} readdir DR) { unlink $files; } closedir DR;

I get this error:

~/perl/sandbox]$ ./newtime.pl Name "main::files" used only once: possible typo at ./newtime.pl line +59. Name "main::isdst" used only once: possible typo at ./newtime.pl line +16. Name "main::yday" used only once: possible typo at ./newtime.pl line 1 +6. The file for this hour already exists! Died at ./newtime.pl line 57.

Line 57 is -> die unless chdir "$backup_weekly_subdir";

I got rid of the chdir part to make it work and used only opendir, but why was this happening with chdir(i mean the die on line 57)? "./backup/weekly" was missing so you were right jethro, but I created it, and it was there, I even printed the variables and tried an ls command on it and it was working... I'm clueless, is this safe what I'm doing, or I can wipe something out that I don't want?


In reply to Re: Need help with mysql dump script by repcsi
in thread Need help with mysql dump script by repcsi

Title:
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, details, 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, summary, 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.