Hi Monks:
I am a newbie to Perl. I am currently a Systems Administrator
in the Washington DC area.
Please I need your assistance. I need to complete the following for
work function but i am still stuck on trying to complete the first
part of the script below. I still can't get script to delete the
files on the V volume on the Window Server.
Implement a script that checks for the available space on
the V and X Volumes on a Window Server 2008 EE.
1. If the available space is less than 3.5 TB on the V Volume,
the script deletes any SyscoDB database backup files
older than 2 weeks.
2. If the available space is less than 3.5 TB on the V Volume,
the scripts moves any SyscoDB database backup files older
than 1 week to the X Volume.
#A script that check If the available space is less
# than 3.5 TB on the V Volume, #and deletes any
#SyscoDB database backup files older than 2 weeks.
#!/usr/bin/perl
use warnings;
use strict;
use Win32::DriveInfo;
my $file;
my $dir_to_process = "V:/Backups/SyscoDB";
my $V_TotalNumberOfFreeBytes = Win32::DriveInfo::DriveSpace('v:');
my $V_RoundedTotalNumberOfFreeGigabytes = sprintf("%.2f",
($V_TotalNumberOfFreeBytes/1073741824));
print "The Free Size is : $V_RoundedTotalNumberOfFreeGigabytes GB\n";
if ( $V_RoundedTotalNumberOfFreeGigabytes < 3.5 &&
$V_RoundedTotalNumberOfFreeGigabytes == 3.5) {
opendir DH, $dir_to_process or
die "Cannot open $dir_to_process: $!";
foreach $file (readdir DH){
unlink $file or warn "failed on $file: $!\n"
if -M $file > 14;
}
closedir DH;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|