forfiles 不在计划任务中工作

发布于 2024-12-09 01:39:13 字数 387 浏览 3 评论 0原文

我创建了一个包含以下行的批处理文件:

forfiles /p L:\percepsrvr\SQL /s /m *.bak /d -4 /c "cmd /c del /q @PATH "

这将删除所有超过 3 天的文件,并且在我运行该批处理文件时起作用。

但是,当我尝试将此批处理文件作为计划任务的一部分运行时,该代码行无法执行。我认为这可能是因为映射的网络驱动器(L:),但不确定。

我以自己的身份运行计划任务,以确保它具有与我手动运行它时相同的权限。计划任务在 Win2008r2 服务器盒上运行,L:\ 在 Win2003 SP2 服务器盒上运行。

任何人都知道什么可能会阻止其正常工作或如何调试计划任务?

TIA 布莱恩

I have created a batch file with the following line:

forfiles /p L:\percepsrvr\SQL /s /m *.bak /d -4 /c "cmd /c del /q @PATH "

This deletes any files older than 3 days and works when I run the batch file.

However, when I try to run this batch file as part of a scheduled task the line of code fails to execute. I think it might be because of the mapped network drive (L:) but don't know for sure.

I have the scheduled task running as myself to make sure it has the same permissions as when I run it manually. The scheduled task is running on a Win2008r2 server box and L:\ is on a Win2003 SP2 server box.

Anyone know what might be keeping this from working properly or how to debug a scheduled task?

TIA
Brian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东风软 2024-12-16 01:39:13

如果有人遇到这篇文章,我找到了如下解决方案:

ROBOCOPY "D:\Backup Data\percepsrvr\SQL" "\\belgrade\v$\percepsrvr\SQL"

ROBOCOPY "\\belgrade\v$\percepsrvr\SQL" "\\belgrade\v$\percepsrvr\SQL\Old" *.* /move /minage:10
DEL "\\belgrade\v$\percepsrvr\SQL\Old\*.*" /Q

基本上,将要删除的文件移动到另一个目录,然后删除该目录(可以使用 RoboCopy 完成)。

In case anyone comes across this post I found a solution as follows:

ROBOCOPY "D:\Backup Data\percepsrvr\SQL" "\\belgrade\v$\percepsrvr\SQL"

ROBOCOPY "\\belgrade\v$\percepsrvr\SQL" "\\belgrade\v$\percepsrvr\SQL\Old" *.* /move /minage:10
DEL "\\belgrade\v$\percepsrvr\SQL\Old\*.*" /Q

Basically, move the files to delete to another directory and then delete that directory (which can be done with RoboCopy).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文