1

I want to delete log files created by my Silverlight application on IIS in a way that the server should check log files older than "n" number of days and delete them automatically.

Is there any configuration in IIS that can do this task or I should write my own utility for it?

1
  • When you think your question is answered, you should mark a question as the right answer. Doing so will make the question apear as solved.
    – Jonathan
    Jan 27, 2012 at 8:58

1 Answer 1

4

There is no configuration switch I'm aware of. You can use the following Powershell script to delete logfiles older than 7 Days in C:\WIN2003\system32\LogFiles\SMTPSVC1 and C:\WIN2003\system32\LogFiles\W3SVC1.

dir C:\WIN2003\system32\LogFiles\SMTPSVC1 |? {$_.LastWriteTime -lt (get-date).AddDays(-7)} | del
dir C:\WIN2003\system32\LogFiles\W3SVC1 |? {$_.LastWriteTime -lt (get-date).AddDays(-7)} | del

Then start this as a planned task once every day. Run the command C:\WIN2003\system32\WindowsPowerShell\v1.0\powershell.exe -file C:\Batch\cleanupLogfiles.ps1 in C:\WIN2003\system32\WindowsPowerShell\v1.0 dir. For this example I assuemed your windows is installed in C:\WIN2003 and your script is C:\Batch\cleanupLogfiles.ps1

3
  • Jon, thanks for the answer.. but my requirement is to automatically delete log files(created by application in a folder on website's virtual directory) without any intervention of a user/admin.
    – asif
    Jan 25, 2012 at 10:35
  • See update above
    – Jonathan
    Jan 25, 2012 at 13:53
  • @asif Any more questions?
    – Jonathan
    Jan 26, 2012 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .