Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: deletes timestamped logfiles (MMDDYY) based on actual time

by blakem (Monsignor)
on Feb 08, 2002 at 01:14 UTC ( [id://144004]=note: print w/replies, xml ) Need Help??


in reply to deletes timestamped logfiles (MMDDYY) based on actual time

If I was going to write this, I would use Time::Piece and the code would look like:
#!/usr/bin/perl -wT use strict; use Time::Piece; my $daysago = 28; my $datadir = "/var/adm"; # MMDDYY of 28 days ago my $timestring = localtime(time-$daysago*24*60*60)->strftime("%m%d%y") +; my $file = "$datadir/backup.$timestring.log.Z"; -e $file or die "File '$file' doesn't exist"; unlink $file or die "Couldn't unlink '$file'";

-Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://144004]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-19 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found