【问题标题】:output file redirection to a log file using batch script with timestamp as file name使用时间戳作为文件名的批处理脚本将输出文件重定向到日志文件
【发布时间】:2012-08-24 08:41:36
【问题描述】:

我们在 Windows 上有一个名为 readfile.pl 的脚本,现在我需要一个批处理脚本来执行此脚本并将输出重定向到每次运行时的新日志文件(批处理不应删除或修改以前的日志文件)和名称日志文件应该类似于 log_date_time.txt。例如,如果 readfile.pl 脚本在 2012 年 8 月 24 日上午 10:30 执行,则日志文件必须是 log_20120824_10_30.log。有人可以帮我解决这个问题吗?

reafile 脚本位于 d:\,日志文件位置为 c:\readlogs

【问题讨论】:

标签: batch-file


【解决方案1】:

不是 100% 确定你要做什么,但试试这个。

command >>log_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%_%time:~3,2%.log

当我回显该命令时会得到什么。

log_20120922_10_33.log

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-26
    • 2020-02-11
    • 2014-08-22
    • 1970-01-01
    • 2013-04-25
    • 1970-01-01
    相关资源
    最近更新 更多