July 6, 2018 at 1:02 pm
I'm using Ola Hallengren's maintenance solution with this command to cleanup old output files. However, it is not working. It deletes nothing and returns no error. Any thoughts as to why this isn't working?
cmd /q /c "For /F "tokens=1 delims=" %v In ('ForFiles /P "\\dba\OutputFiles" /m *_*_*_*.txt /d -30 2^>^&1') do if EXIST "\\dba\OutputFiles"\%v echo del "\\dba\OutputFiles"\%v& del "\\dba\OutputFiles"\%v"
July 7, 2018 at 3:19 am
Samwell - Friday, July 6, 2018 1:02 PMI'm using Ola Hallengren's maintenance solution with this command to cleanup old output files. However, it is not working. It deletes nothing and returns no error. Any thoughts as to why this isn't working?cmd /q /c "For /F "tokens=1 delims=" %v In ('ForFiles /P "\\dba\OutputFiles" /m *_*_*_*.txt /d -30 2^>^&1') do if EXIST "\\dba\OutputFiles"\%v echo del "\\dba\OutputFiles"\%v& del "\\dba\OutputFiles"\%v"
Have you checked the permissions on the \\dba\OutputFiles file share?
😎
If the process is running as a local service account, it will not have the necessary permissions.
July 9, 2018 at 5:50 am
It's running as a SQL Agent job and the service account running SQL Agent has permissions to that folder. It can create the files.
July 9, 2018 at 11:36 am
Samwell - Monday, July 9, 2018 5:50 AMIt's running as a SQL Agent job and the service account running SQL Agent has permissions to that folder. It can create the files.
Could be the fact that there's no space prior to the "&".
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply