Windows批处理脚本:写入日志文件导致"used by another process"
Windows Batch Script: Writing to log file causes "used by another process"
我需要更新多个 SVN 工作副本。我想将其写入日志文件,但这是不可能的,因为一个 SVN 更新只需要几秒钟,而另一个可能长达几分钟。
因此,我总是收到以下消息:
The process cannot access the file because it is being used by another process.
我正在使用此代码:
@echo off
echo.
:: Setting Variables
set SVN_BIN=C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
set LOG_FILE=D:\BatchScripts\logs\svn-update.log
set CMD_TITLE="SVNUpdate"
set SOURCE1=D:\www\upload.example.com\
set SOURCE2=D:\www\download.example.com\
set SOURCE3=D:\www\client.example.com\
::
::
echo. %DATE% %TIME% Updating %SOURCE1% using SVN... >> "%LOG_FILE%"
START "%CMD_TITLE%" "%SVN_BIN%" /command:update /path:"%SOURCE1%" /closeonend:1 >> "%LOG_FILE%"
::
echo. %DATE% %TIME% Updating %SOURCE2% using SVN... >> "%LOG_FILE%"
START "%CMD_TITLE%" "%SVN_BIN%" /command:update /path:"%SOURCE2%" /closeonend:1 >> "%LOG_FILE%"
::
echo. %DATE% %TIME% Updating %SOURCE3% using SVN... >> "%LOG_FILE%"
START "%CMD_TITLE%" "%SVN_BIN%" /command:update /path:"%SOURCE3%" /closeonend:1 >> "%LOG_FILE%"
::
echo. %DATE% %TIME% Operation complete. >> "%LOG_FILE%"
如何归档写入日志文件?该脚本将使用 Windows 任务计划程序每 5 分钟执行一次。
START
参数 /wait
没有帮助或解决问题,但它确实大大减慢了更新过程,因为它总是等待当前 SVN 更新完成,然后,它将开始下一次更新。这不是,我想要的。
TortoiseProc.exe 不是完成此任务的工具。对于这种自动化,您应该使用 svn.exe
。阅读 documentation:
Remember that TortoiseSVN is a GUI client, and this automation guide
shows you how to make the TortoiseSVN dialogs appear to collect user
input. If you want to write a script which requires no input, you
should use the official Subversion command line client instead.
我需要更新多个 SVN 工作副本。我想将其写入日志文件,但这是不可能的,因为一个 SVN 更新只需要几秒钟,而另一个可能长达几分钟。
因此,我总是收到以下消息:
The process cannot access the file because it is being used by another process.
我正在使用此代码:
@echo off
echo.
:: Setting Variables
set SVN_BIN=C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
set LOG_FILE=D:\BatchScripts\logs\svn-update.log
set CMD_TITLE="SVNUpdate"
set SOURCE1=D:\www\upload.example.com\
set SOURCE2=D:\www\download.example.com\
set SOURCE3=D:\www\client.example.com\
::
::
echo. %DATE% %TIME% Updating %SOURCE1% using SVN... >> "%LOG_FILE%"
START "%CMD_TITLE%" "%SVN_BIN%" /command:update /path:"%SOURCE1%" /closeonend:1 >> "%LOG_FILE%"
::
echo. %DATE% %TIME% Updating %SOURCE2% using SVN... >> "%LOG_FILE%"
START "%CMD_TITLE%" "%SVN_BIN%" /command:update /path:"%SOURCE2%" /closeonend:1 >> "%LOG_FILE%"
::
echo. %DATE% %TIME% Updating %SOURCE3% using SVN... >> "%LOG_FILE%"
START "%CMD_TITLE%" "%SVN_BIN%" /command:update /path:"%SOURCE3%" /closeonend:1 >> "%LOG_FILE%"
::
echo. %DATE% %TIME% Operation complete. >> "%LOG_FILE%"
如何归档写入日志文件?该脚本将使用 Windows 任务计划程序每 5 分钟执行一次。
START
参数 /wait
没有帮助或解决问题,但它确实大大减慢了更新过程,因为它总是等待当前 SVN 更新完成,然后,它将开始下一次更新。这不是,我想要的。
TortoiseProc.exe 不是完成此任务的工具。对于这种自动化,您应该使用 svn.exe
。阅读 documentation:
Remember that TortoiseSVN is a GUI client, and this automation guide shows you how to make the TortoiseSVN dialogs appear to collect user input. If you want to write a script which requires no input, you should use the official Subversion command line client instead.