Page Properties | ||||||
---|---|---|---|---|---|---|
| ||||||
|
...
Using a text editor create a bat file, saving with a '.bat' extension e.g. 'D:\iShareData\batfiles\deltemp.bat'
Code Block rem Remove MapServer temporary files del /F /Q D:\mapserver\tmp\*.png >nul 2>&1 del /F /Q D:\mapserver\tmp\*.log >nul 2>&1 del /F /Q D:\mapserver\tmp\logs\*.log >nul 2>&1 rem Remove LIVE iShare SLD del /F /Q D:\Astun\iShareGIS\n.n\WebApps\WebService\SLD\*.xml >nul 2>&1 del /F /Q D:\Astun\iShare\n.n\WebApps\WebService\SLD\*.xml >nul 2>&1 rem Remove TEST iShare SLD del /F /Q D:\Astun\iShareGIS\n.nTest\WebApps\WebService\SLD\*.xml >nul 2>&1 del /F /Q D:\Astun\iShare\n.nTest\WebApps\WebService\SLD\*.xml >nul 2>&1 rem Remove PostgreSQL Log files forfiles -p "D:\PGDATA\pg_log" -s -m "*.log" -d -5 -c "cmd /c del @path" >nul 2>&1 rem Remove SLD temporary .map files from Windows Temp del /F /Q C:\Windows\Temp\*.map >nul 2>&1
- You may choose to run this directly from the command line at this point to check that the correct files are removed (also looking at potential error messages within the command prompt window).
- Create a Studio task to run the bat file, within Studio create a new Program task (New Task > Program)
- Name the task, e.g. 'Delete MapServer tmp and logs'
Within the Task Details Panel enter (or navigate to) 'D:\iShareData\batfiles\deltemp.bat' in the Program field.
Note If you are browsing to select your .bat file you will need to change the file types to be All files (*.*) otherwise you will only see .exe entries.
Make sure to Save the task and test that it runs as expected.Finally set up a Studio Workflow Job to run this as a Scheduled task on e.g. a monthly, weekly or daily basis.
Tip Make sure that the account you use to run the Job has permission to delete files from all of the folders in your .bat file. If not you will see errors such as "Unable to delete files from mapserver\tmp" and this could then cause the disk to fill up.
Note It is not unusual to see an error message in the iShare logs if you run the task when no .log or .png files exist in the specified locations in your .bat file e.g. Error: Could Not Find D:\mapserver\tmp\*.png
...
- Create a Studio Workflow Program Task to run the Powershell Script (New Task > Program)
- Name the Task e.g. 'Delete IIS Logs over a week old'
- Use the browse button to select the powershell.exe program from the Windows folder e.g. c:\windows\syswow64\windowspowershell\v1.0\powershell.exe in the Program field.
In the Additional Parameters you need to enter the following details.
Paste code macro -ExecutionPolicy Bypass d:\astun\Tools\Powershell\DeleteFiles.ps1 -path C:\inetpub\logs\LogFiles\ -filespec *.log -age 168 -recurse $true commit $true
By using -recurse $true it will check all the sub folders and the -age 168 denotes the number of hours old a file needs to be before it is deleted. If you need information on all of the parameters please see Run the DeleteFiles Powershell Script.
- Make sure to Save the task and test that it runs as expected.
Finally set up a Studio Workflow Job to run this as a Scheduled task on e.g. a monthly, weekly or daily basis.
Tip Make sure that the account you use to run the Job has permission to delete files from all of the C:\inetpub\logs\LogFiles\ folder.