Created
November 18, 2014 16:21
-
-
Save devscott/cccc5e0eda04b104bb9e to your computer and use it in GitHub Desktop.
Windows batch script to rotate Putty logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM This closes the active session of Putty to allow the log files to be modified and waits 2 seconds | |
taskkill /F /IM putty.exe | |
ping -n 2 -w 1000 127.0.0.1 > nul | |
REM This makes a copy of the latest log appending todays date to the file name and waits 2 seconds | |
copy "X:\Users\Common\TestLog.log" "X:\Users\Common\TestLog_%DATE:/=%.log" | |
ping -n 2 -w 1000 127.0.0.1 > nul | |
REM Manually create a blank log file in the same directory call Blank.Log | |
REM This makes a copy of the Blank log replacing the active file with a clean file and waits 2 seconds | |
copy "X:\Users\Common\Blank.log" "X:\Users\Common\TestLog.log" | |
ping -n 2 -w 1000 127.0.0.1 > nul | |
REM This launches Putty using the saved session with the TestLog Putty profile details | |
start putty.exe -load "TestLog" | |
REM Add this batch file to scheduled tasks to save a copy and clear the log file daily, weekly, or monthly | |
REM Time delays were added for testing and can likely be removed in most cases. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment