delete old SSIS log files using maintenance plan

  • We have a SSIS log folder that has a lot of daily log files for SSIS packages.

    I am hoping to use maintenance plan to delete the files.

    So I chose the task of maintenace clean up task, and browse to the folder, and put the extension txt.

    and select older than one hour to test.

    But no files are deleted,

    is it because this only applies to backup filea nd maintenance plan report file?

    but look at the SQl it genreate:

    it is :

    EXECUTE master.dbo.xp_delete_file 1,N'D:\_SSISFILES\Log\' ,N'txt',N'2013-07-24T10:19:31',1

    So I guess it should not matter what files are they, as log as it has an extension of txt.

    But why it is not working?

    THanks

  • You could also build an SSIS package to do this with the File System Task. (or with some .NET code)

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Have a look at this. It seems that xp_delete_file goes into the file itself and checks the header. Looks like you may have to roll your own, as Koen suggests.

    John

  • I use microsoft utility FORFILES to delete old files and schedule it through SQL agent. I think the syntax varies depending on your version of Windows.

    For me on Windows server 2003, this is one script I use to delete *.* files in a specific folder older than 180 days:

    forfiles /p "i:\objectscripts" /s /m *.* /c "cmd /c del @path" /d -180

    Quirk: The SQL job will show failed if there are no files to delete.

  • Thanks, all, you are right , I hope use that maintenance plan task as an easier way to do the clean up, now I got to know it doesn't work for all kinds files with extension, it not only looks at extension, but also the header of text.

    I like the idea of using forfiles, I forgot I used that for a couple of our web servers IIS log cleanup, I will reuse that too.

    Thanks,

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

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