Delete the two months old log files

90 pts.
Tags:
Log files
Log folder
Hi, Basically it has to find out the two month old files by comparing the time stamp with another files according to that I have to delete the two month old files in the log folder. It has to find out the two month old log files by compare the today date.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is a sample monthly scheduled task to automatically delete
logfiles older than 30 days. The Windows server command which will be used for this is:

forfiles /P c:\windows\system32\logfiles /S /M *.log /D -30 /C “cmd /c del /F @path”

Modify the path and number of days as needed.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    What platform? What creates the "log files"? Can the log creator be configured to 'roll' its logs? Are backups needed? (If not, why keep logs for so long? Why not delete them daily?) What programming experience do you have? A solution that's useful to you will depend on those factors and possibly others. -- Tom
    125,585 pointsBadges:
    report
  • santtomcat
    hi , just i need a script(.bat file) it has to remove the two month older log files in the windows server. so that i will put this script in task scheduler.
    90 pointsBadges:
    report
  • carlosdl
    Hi santtomcat.  Take a look at the script provided here: VB Script to delete old files fom the local and/or remote computer(s)
    70,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following