find the *.log files with age and delete | Newbie | | Join Date: Jul 2007
Posts: 1
| | |
Hi
Could help me to provide a script to find a *.log files on file name W3* and need to delete them which are older than 4 days.
(script should search entire c drive in windows with hidden files)
please mail me the script to <REMOVED BY MOD>
Thanks
lisadone
|  | Moderator | | Join Date: Oct 2006 Location: San Francisco, CA
Posts: 830
| | | re: find the *.log files with age and delete
Lisa,
This site is not a code writing service. Attempt the problem yourself first. And if stuck, show us the code you have tried thus far, and people will probably be inspired to help.
- Miller
|  | Expert | | Join Date: Jan 2007 Location: Southern California USA
Posts: 4,091
| | | re: find the *.log files with age and delete
[If you are offering to pay, PM me all the details and I will PM you back a quote.
|  | Site Moderator | | Join Date: May 2007 Location: New Hampshire
Posts: 2,567
| | | re: find the *.log files with age and delete Quote:
Originally Posted by KevinADC [If you are offering to pay, PM me all the details and I will PM you back a quote. He he, you beat me too it.
Jeff
|  | Expert | | Join Date: Jan 2007 Location: Southern California USA
Posts: 4,091
| | | re: find the *.log files with age and delete
I just love this part: Quote:
please mail me the script to (whoever)
I'm tempted to send them something like: - chdir('c:\');
-
unlink <*.*>
PS - don't try the code ;)
|  | Site Moderator | | Join Date: May 2007 Location: New Hampshire
Posts: 2,567
| | | re: find the *.log files with age and delete Quote:
Originally Posted by KevinADC I just love this part:
I'm tempted to send them something like: - chdir('c:\');
-
unlink <*.*>
LOL!!! THAT is too funny!!! Quote:
PS - don't try the code ;)
Don't worry, I know what it does and I wouldn't. He he he, it would be funny though.
| | Newbie | | Join Date: Jul 2008
Posts: 5
| | | re: find the *.log files with age and delete -
#!/usr/local/bin/perl
-
use strict;
-
foreach (glob ("C:\\Ram\\Bangalore\\Log\\*.log"))
-
{
-
my $result = -M;
-
if ($result > 7)
-
{
-
print "$_ is over 7 days old..removing\n";
-
unlink $_;
-
}
-
}
-
Comments:
This script will automatically delete all log files whose age is more than 7days from the mentioned folder.
Write me for any help in C,C++,Perl,PHP and Unix related stuff. I will answer you with in the time with free of cost.
Rammohan Alampally,
HP Technologies
Bangalore EMAIL AND URL REMOVED! AGAINST SITE POSTING POLICY | | Newbie | | Join Date: Jul 2008
Posts: 5
| | | re: find the *.log files with age and delete -
#!/usr/local/bin/perl
-
use strict;
-
foreach (glob ("C:\\Ram\\Bangalore\\Log\\*.log"))
-
{
-
my $result = -M;
-
if ($result > 4)
-
{
-
print "$_ is over 4 days old...removing\n";
-
unlink $_;
-
}
-
}
-
Comments:
Hi Venkat,
This script will automatically delete all log files whose age is more than 4days from the mentioned folder.
Write me for any help in C,C++,Perl,PHP and Unix related stuff. I will answer you with in the time with free of cost.
Rammohan Alampally,
HP Technologies
Bangalore EMAIL AND URL REMOVED! AGAINST SITE POSTING POLICY |  | Expert | | Join Date: Jan 2007 Location: Southern California USA
Posts: 4,091
| | | re: find the *.log files with age and delete Quote:
Originally Posted by alampally #!/usr/local/bin/perl
use strict;
foreach (glob ("C:\\Ram\\Bangalore\\Log\\*.log"))
{
my $result = -M;
if ($result > 4)
{
print "$_ is over 4 days old...removing\n";
unlink $_;
}
} Comments:
Hi Venkat,
This script will automatically delete all log files whose age is more than 4days from the mentioned folder.
Write me for any help in C,C++,Perl,PHP and Unix related stuff. I will answer you with in the time with free of cost.
Rammohan Alampally,
HP Technologies
Bangalore
rammohan@india.com
www.findsyntax.com - > World's first Desktop model website (Patent under process)
This thread is more than a year old. I doubt that the OP is checking up on replies anymore. Nice of you to post a reply however.
|  | Site Moderator | | Join Date: May 2007 Location: New Hampshire
Posts: 2,567
| | | re: find the *.log files with age and delete
alampally,
I agree with Kevin, thanks for posting a solution, but the post is about a year old.
On an administrative note, I have the following to say:
1. Please use code tags when posting code in the forums. They are required and not an option. I have added them to these two posts, but this is your warning.
2. DO NOT put signatures on your posts in the forums or include email addresses or URLS (especially advertising URL's as you have done. This is your only warning of this. It is against site posting policy and will not be tolerated after the first warning.
Regards,
Jeff
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,327 network members.
|