由于其他进程句柄,Bat 文件 MOVE 失败
我有一个bat文件,作为大型维护系统的一部分,该系统每晚运行,执行一些内务管理、SVN更新等。其中一部分涉及移动/删除文件,但是,偶尔会由于另一个进程未释放句柄而失败在要移动的文件/目录上。有没有办法强制 BAT 文件覆盖任何现有句柄并继续 MOVE?我只能想到使用 ProcessExplorer/Assassin 的查找方法 - 尽管我不确定这是否有效。或者,如果第一次失败,则“睡眠”,然后重新尝试,尽管这比解决根本问题要靠运气。非常感谢任何想法/建议。谢谢。
I have a bat file as part of larger maintenance system that runs on a nightly basis, performs a bit of housekeeping, SVN updating etc. Part of this involves moving/deleting files, however, occasionally this fails due to another process not releasing a handle on the files/dirs to be moved. Is there any way to force the BAT file to override any existing handles and continue with the MOVE? I can only think of a look up method using ProcessExplorer/Assassin - although I'm not sure that would even work. Alternatively a "sleep" and then reattempt if it failed the first time, although that would be a matter of luck than solving the underlying problem. Any ideas/suggestions much appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Robocopy具有移动功能,并且可以等待错误
Robocopy has a move function, and can wait on error
以下是我在类似情况下所做的一些事情:
move
命令之前,确保其他脚本将CD
线程移出目标目录。/r:3
等选项并等待 <代码>/w:5。MOVE
命令。Here are a few things that I have done in similar situations:
move
command, ensure that other script threadsCD
out of the target directory./r:3
and wait/w:5
.COPY
so the script can continue working, then later in the script do the deletion at the old/unneeded location.MOVE
command.