windows - How to append the data in the log file when the batch file is executed -
i wanted append contents of log file when ran batch file often, code im using in batch file create log file contains data present in console call test1.bat >logfile.log 2>&1 create log file once , not delete or append data in log file.. please me out solve issue. content of file
@echo off cd /d %~dp0 set day=-1 echo >"%temp%\%~n0.vbs" s=dateadd("d",%day%,now) : d=weekday(s) echo>>"%temp%\%~n0.vbs" wscript.echo year(s)^& right(100+month(s),2)^& right(100+day(s),2) /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') set "result=%%a" del "%temp%\%~n0.vbs" set "yyyy=%result:~0,4%" set "mm=%result:~4,2%" set "dd=%result:~6,2%" set "data=%yyyy%-%mm%-%dd%" echo yesterday "%data%" set year=%data:~0,4% set month=%date:~4,2% set day=%data:~8,3% set filename=login_%year%-%month%-%day%.log.gz echo filename = %filename% c:\wamp\bin\php\php5.3.9\php.exe c:\wamp\www\f\csv\index.php call test1.bat >>logfile.log 2>&1 pause
call test1.bat >>logfile.log 2>&1 like in every shell >> appending.check this.
Comments
Post a Comment