Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

delete log file Expand / Collapse
Author
Message
Posted Tuesday, August 14, 2012 6:00 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, April 7, 2016 12:35 PM
Points: 1,910, Visits: 3,580
I would like to use http://ola.hallengren.com/ script.

There are log output files created in the folder of MSSQL\log.

How can I setup a job to delete the old ones, I don't see that is include in maintenance job.

Or I missed it?

Thanks
Post #1345091
Posted Tuesday, August 14, 2012 11:46 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, October 7, 2015 1:11 PM
Points: 172, Visits: 1,938
There is a job, [Output File Cleanup], that is taking care of that. It is created by http://ola.hallengren.com/scripts/MaintenanceSolution.sql.

Ola Hallengren
http://ola.hallengren.com
Post #1345132
Posted Wednesday, August 15, 2012 9:07 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, April 7, 2016 12:35 PM
Points: 1,910, Visits: 3,580
Thanks a lot. I will check into it.
Post #1345327
Posted Thursday, February 18, 2016 9:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 12, 2016 10:24 AM
Points: 2, Visits: 165
One thing we recently learned about the command created in Ola's output file cleanup job is that if you are using a UNC path for your backups and/or Agent Job log files then the CmdExe script will not work as UNC paths are not supported.

In our case and as a temporary solution, since we have a 3 node cluster using SQL 2014 Availability Groups where only the backup volumes are leveraging the same shared storage volumes for our backups, we opted for just altering the Output File Cleanup jobs to use the physical drive letters since these shared volumes are usually hosted on the same node. Of course I the event of a failover we would have to make a manual adjustment but that is a better option than not cleaning up the Agent job files at all.
Post #1762435
Posted Tuesday, March 1, 2016 8:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 1, 2016 11:44 PM
Points: 1, Visits: 6
I looked at the "Output File Cleanup" Job in Ola Hallengrens script and rewrote it in powershell.

Turning this:

cmd /q /c "For /F "tokens=1 delims=" %v In ('ForFiles /P "$(ESCAPE_SQUOTE(SQLLOGDIR))" /m *_*_*_*.txt /d -30 2^>^&1') do if EXIST "$(ESCAPE_SQUOTE(SQLLOGDIR))"\%v echo del "$(ESCAPE_SQUOTE(SQLLOGDIR))"\%v& del "$(ESCAPE_SQUOTE(SQLLOGDIR))"\%v"

Into this:

powershell.exe -command & {get-childitem -path "$(ESCAPE_SQUOTE(SQLLOGDIR))"  -filter *_*_*_*.txt | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | remove-item -verbose}

It should handle UNC paths and i think it is a little bit easier on the eye. Cmd is probably faster to execute and it will probably work the same pretty much anywhere, the powershell snippet above has not been tested in production so be aware of that. I just did it for the sake of learning and i did it on SQL Server 2014 SP1 Enterprise. But if anyone else finds it useful, nobody is happier than me. :)
Post #1765594
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse