我试图编写一个batch-file来模拟一个ping
请求的睡眠。
代码如下:
echo STARTED-^> %DATE% - %TIME%>> c:\Italprogetti\logfile.log
ping 127.0.0.1 -n 3 > nul
for /L %%x IN (1,1,10) do (
echo EXECUTED-^>%%x %DATE% - %TIME% >> c:\Italprogetti\logfile.log
ping 127.0.0.1 -n 3 > nul
)
echo ENDED-^> %DATE% - %TIME%>> c:\Italprogetti\logfile.log
问题是:为什么%TIME%
在整个周期内都保持不变?
这是我的输出:
STARTED-> 21/05/2019 - 11:17:25,36
EXECUTED->1 21/05/2019 - 11:17:27,38
EXECUTED->2 21/05/2019 - 11:17:27,38
EXECUTED->3 21/05/2019 - 11:17:27,38
EXECUTED->4 21/05/2019 - 11:17:27,38
EXECUTED->5 21/05/2019 - 11:17:27,38
EXECUTED->6 21/05/2019 - 11:17:27,38
EXECUTED->7 21/05/2019 - 11:17:27,38
EXECUTED->8 21/05/2019 - 11:17:27,38
EXECUTED->9 21/05/2019 - 11:17:27,38
EXECUTED->10 21/05/2019 - 11:17:27,38
ENDED-> 21/05/2019 - 11:17:47,58
谢谢, 费德里科