Ola Hallengrens - Output File cleanup does not delete files We run Ola Hallengrens backup,dbcc &amp; index jobs but we have not scheduled Output File Cleanup for some reason. Noticed this today and when we tried to run it on a server that had 2 or more instances it doesn't delete old logs.
We have for example set up 1 server with 2 instances and it's set up with AvailabilityGroups.
When running the script this is the output: (I've deleted a few rows so it didn't take up the whole page but it deleted a few files)


  Date      2017-07-04 10:57:55 Log     Job History (Output File Cleanup)
  
  Step ID       1 Server        SERVER1183\INST01 Job Name      Output File Cleanup
  Step Name     Output File Cleanup Duration        00:01:54 Sql Severity   0 Sql
  Message ID    0 Operator Emailed   Operator Net sent   Operator Paged 
  Retries Attempted 0
  
  Message Executed as user: VT\sqladmin-internaltes.
  ...8C0E25584E08C4CB393567C2C66083E_1_20170301_132833.txt"  del
  "E:\MSSQL\INST01\MSSQL12.INST01\MSSQL\Log"\"DatabaseBackup_0x18C0E25584E08C4CB393567C2C66083E_1_20170304_200000.txt"
  del
  "E:\MSSQL\INST01\MSSQL12.INST01\MSSQL\Log"\"DatabaseBackup_0x6DFC82E95...
  Process Exit Code 0.  The step succeeded.


After checking in the Logs folder which is located: E:\MSSQL\INST01\MSSQL12.INST01\MSSQL\Log we still have 12500 files. 

The jobs are set up as standard when adding Olas jobs, with output file config:

$(ESCAPE_SQUOTE(SQLLOGDIR))\IndexOptimize_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt


We have not changed the job command at all which is:

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


The script works fine when it's a single instance or default instance.
It's sql 2014 if that's relevant but we have this problem on 2008 &amp; 2012 aswell.

Anyone got this figured out or know how to fix this?
I should add that this works fine with 2 or more instances that are not set up with availability groups. It's only when it's more then 1 instance and AG set up. But what I did instead was to edit the parameters and change $(ESCAPE_SQUOTE(SQLLOGDIR)) to the actual path folder and it worked great.