简体   繁体   English

执行批处理文件时如何在日志文件中追加数据

[英]How to append the data in the log file when the batch file is executed

I wanted to append the contents of the log file when i ran batch file often, code im using in batch file to create a log file which contains data present in the console is call test1.bat >logfile.log 2>&1 This only create the log file once and will not delete or append the data in the log file.. Please help me out to solve this issue. 当我经常运行批处理文件时,我想附加日志文件的内容,代码im在批处理文件中使用以创建包含控制台中存在的数据的日志文件,称为test1.bat> logfile.log 2>&1仅此创建日志文件一次,并且不会删除或将数据附加到日志文件中。请帮助我解决此问题。 this is the content of the 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)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do 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 was "%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

像每一个壳>>是appending.Check也是这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检测批处理文件的执行方式 - Detecting how a batch file was executed 尝试在后台运行时未执行批处理文件 - Batch file not executed when trying to run in background 从另一个批处理文件调用该批处理文件时,批处理文件中的复制命令未得到执行,但是当我双击时,该命令正在执行 - copy command in batch file is not getting executed when calling the batch file from another batch file, but is getting executed when i double click 窗口启动时如何运行批处理文件? (登录问题) - How to run a batch file when window starts up? (log in issue) 如何在Windows XP上将日期附加到批处理文件 - How to append date to batch file on Windows XP 使用Windows批处理命令附加到文件时,如何在文件中的下一个单词之后立即附加? - When appending to a file using Windows batch commands, how to append immediately after the next word in the file? 不从批处理文件执行for循环 - For loop is not executed from batch file 当应用程序执行批处理文件时重定向命令输出 - Redirecting command output when batch file is executed by an application 当用ProcessBuilder执行Java时,为什么Java无法打开批处理文件? - Why will Java not open up a Batch file when executed with a ProcessBuilder? 从批处理文件执行时 ICACLS 表现怪异 - ICACLS behaving weird when executed from batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM