Cleanup txt files from Z:\drive issue?

  • I have job setup on all the PROD servers(2005, 2008r2, 2012).

    The Job will generate a .txt file every day for each database to scripts out permission.

    And saving a permission scripts for 5day and do clean up.

    Here is the issue,

    I am doing maintenance cleanup task(maintenance plan) to do a cleanup,

    But it is not working, It does not clean up the .txt file on any of the servers (2005, 2008r2, 2012).

    what was the issue? Do I am doing wrong way to do cleanup?

    any alternate solution do do clean up?

    example my file name conversation are: DBname_DBuserlist_20121009

  • Does your Maintenance Plan Cleanup task look like this? Note the lack of a dot (.) in the File extension box. Also, if you're creating directories for each DB, you'll need to check the box next to "Include first-level subfolders". Also make sure the folder path is correct if you're not placing the files on the root of Z:

  • Yes looks the same

  • Do the accounts for SQL Server and SQL Server Agent have permissions to the path you're attempting to delete files in? How are you executing the Maintenance Plan, through a SQL Server Agent job?

  • Using SA account.

    All my .bak backup cleanup history works fine, cleanups after 48Hrs.

    I doesn't work for my txt file to cleanup. These txt file are created by job in process, these are not report txt files.

    Is there is way, I can create a job step to clean up txt files

    any help please!

  • Danzz (10/10/2012)


    Using SA account.

    All my .bak backup cleanup history works fine, cleanups after 48Hrs.

    I doesn't work for my txt file to cleanup. These txt file are created by job in process, these are not report txt files.

    Is there is way, I can create a job step to clean up txt files

    any help please!

    The maintenance plan file cleanup tasks only cleanup backup files created by maintenance plans or report text files created by maintenance plans.

    You could use ActiveX , Command shell, or Powershell to cleanup the txt files.

  • Thanks Michael!

    Can I get a command of (ActiveX , Command shell, or Powershell)

    example my file name are: DBname_DBuserlist_20121009.txt

    Location Z:\Permissions\

  • The TechNet site is a good place to start. I believe there are several "delete files older than X" type scripts there:

    http://gallery.technet.microsoft.com/scriptcenter/site/search?f%5B0%5D.Type=ProgrammingLanguage&f%5B0%5D.Value=PowerShell&f%5B0%5D.Text=PowerShell%5B/url%5D

  • Thanks !

Viewing 9 posts - 1 through 8 (of 8 total)

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