clean up old ssrs log files

  • We have a reporting server using SSRS, it sometimes created big log files, and run out of disk space.

    I would like to set up a job to delete those logs older than a week.

    Can I use maintenance plan to do that, I see there is a maintenance clean up task, but it can only delete backup files and maintenance plan text reports, can I just use the second option, and put the SSRS log files folder and extension= log to clean up the logs.

    We are using SQL 2008 for this server, it seems in the Reporting configure file ReportingServicesService.exe, it says <add name="KeepFilesForDays" value="14" />

    I assume it means it will clean up any files older than 14 days.

    Not sure if it is working or not.

  • this sounds like a job more for PowerShell than SQL Server. SQL Server only has limited functionality for file processing.

    https://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09

  • We are using SQL 2008 for this server, it seems in the Reporting configure file ReportingServicesService.exe, it says <add name="KeepFilesForDays" value="14" />

    I assume it means it will clean up any files older than 14 days.

    Not sure if it is working or not.

    It's a bug that wasn't fixed until 2008R2...so no it's not working in your case. I'd go the route of using a Powershell as Chris suggested, you could just have a powershell job step to delete the files.

    Sue

  • Thanks, Yes, I scheduled a cmd forfile job in SQL agent to delete the files.

  • put this PoSh code into a PS1 script and run it via sql agent

    $checkdate = (get-date).AddDays(-14)

    $checkpath = "drive:\path\path\"

    get-childitem $checkpath -Include *.old | ?{$_.LastWriteTime -lt $checkdate} | remove-item

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply