469,366 Members | 2,286 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

find the *.log files with age and delete

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
Jul 2 '07 #1
9 4821
miller
1,089 Expert 1GB
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
Jul 2 '07 #2
KevinADC
4,059 Expert 2GB
[If you are offering to pay, PM me all the details and I will PM you back a quote.
Jul 2 '07 #3
numberwhun
3,503 Expert Mod 2GB
[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
Jul 3 '07 #4
KevinADC
4,059 Expert 2GB
I just love this part:

please mail me the script to (whoever)
I'm tempted to send them something like:

Expand|Select|Wrap|Line Numbers
  1. chdir('c:\');
  2. unlink <*.*>
PS - don't try the code ;)
Jul 3 '07 #5
numberwhun
3,503 Expert Mod 2GB
I just love this part:



I'm tempted to send them something like:

Expand|Select|Wrap|Line Numbers
  1. chdir('c:\');
  2. unlink <*.*>
LOL!!! THAT is too funny!!!

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.
Jul 3 '07 #6
Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl
  2. use strict;
  3. foreach (glob ("C:\\Ram\\Bangalore\\Log\\*.log"))
  4. {
  5.     my $result = -M;
  6.     if ($result > 7)
  7.     {
  8.         print "$_ is over 7 days old..removing\n";
  9.         unlink $_;
  10.     } 
  11. }
  12.  
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
Jul 16 '08 #7
Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl
  2. use strict;
  3. foreach (glob ("C:\\Ram\\Bangalore\\Log\\*.log"))
  4. {
  5.     my $result = -M;
  6.     if ($result > 4)
  7.     {
  8.         print "$_ is over 4 days old...removing\n";
  9.         unlink $_;
  10.     } 
  11. }
  12.  
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
Jul 16 '08 #8
KevinADC
4,059 Expert 2GB
#!/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.
Jul 16 '08 #9
numberwhun
3,503 Expert Mod 2GB
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
Jul 16 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Ralph Freshour | last post: by
5 posts views Thread by Jobs | last post: by
12 posts views Thread by hokiegal99 | last post: by
reply views Thread by Steve | last post: by
2 posts views Thread by Keith Smith | last post: by
7 posts views Thread by eSolTec, Inc. 501(c)(3) | last post: by
5 posts views Thread by gdorian | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.