For various windows servers I had to decrease the amount of log files on the server itself. Therefore I decided the go with the following strategy:
- leave 3 days of log files as-is on the server
- files which are older then 3 day's need to be zipped and I keep a copy on the server
- files which are older then 60 day's can be deleted because they have already copied onto an additional storage (but this copy is a different szenario and I explain about it in a different blog post)
- 7-zip
- forfiles.exe (you can download a rar file from my shared cache website)
- Windows Task Scheduler
- one bat file
The following 3 lines you multiply as much as needed for each WsSVC[n] folder and save it into a *.bat file.
@echo START - %TIME%
forfiles -p "E:\LogFiles\W3SVC1" -s -m *.log -d -3 -c "Cmd /C 7z a @FILE.zip @FILE"
forfiles -p "E:\LogFiles\W3SVC1" -s -m *.log -d -3 -c "cmd /c del @file"
forfiles -p "E:\LogFiles\W3SVC1" -s -m *.zip -d -60 -c "cmd /c del @file"
@echo DONE - %TIME%
I had to compress 24 folder with log filesAll files together had a size 684 MB - well quite a lot for log files but they get very fast very big therefore I really suggest to implement this approach.
For my scripting convenience I've added the installation paths into environment path variable:
- Open System properties
- Click on Environment Variables
- Search for PATH and then click edit
- Add both full paths to 7zip and forfiles.exe
Now open your Task Scheduler and create a new Task:
Once you done with the configuration you should make a test run with your task.
The result is that I could save 636 MB on my hard disc on the live server. This space can be used for many other things
No comments:
Post a Comment