Created
July 10, 2021 03:53
-
-
Save oshinko/cfe3f54657911001be60ed675de44d58 to your computer and use it in GitHub Desktop.
Add timestamp to log file on Windows.
This file contains hidden or 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
set logfile=%computername%.log.txt | |
set maxlines=1024 | |
set /a taillines=%maxlines%-1 | |
cd %~dp0 | |
powershell -command "Get-Content %logfile% -Tail %taillines%" 1> tmp.txt 2> nul | |
type tmp.txt > %logfile% | |
echo %date% %time% >> %logfile% | |
del tmp.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment