Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File to delete log files

Status
Not open for further replies.

forkEP

MIS
Feb 20, 2005
11
US
I surfed around the net and really wasn't able to find any batch files to delete IIS log files. The closest I was able to come was to delete all files in the log folder based on the file age. This batch file will delete all files in the named folder that are over 1 day old:

@echo off
forfiles -p C:\"PATH TO LOG FOLDER" -s -m *.* -d -1 -c "CMD /C Del @FILE"

This does not delete the current log file, which is not possible because IIS wont let you.

I hope this helps somebody not waste their night surfing the net ;)

 
robocopy can be used to move all files that are over a certain age into another folder, then simply delete everything in this new folder.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Thx for the option. I wanted to avoid any new programs on my server. Thats why I was trying so hard to find a batch file option. ;)
 
Robocopy comes with Windows 2003. It's part of the support kit. Windows Windows 2000 and Windows NT its part of the Resource kit. It's a Microsoft command line program.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Well now... If only I had realized that BEFORE wasting my time looking to make a batch file ahhaha. Oh well, thank you much for the information, and I will definately look into utilizing that program in the future.
 
no problem :)

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top