Cron 作业指示错误 - mv: cannot access <filename> 但文件已移动

Posted

技术标签:

【中文标题】Cron 作业指示错误 - mv: cannot access <filename> 但文件已移动【英文标题】:Cron job indicates error - mv: cannot access <filename> but the files have moved 【发布时间】:2020-12-09 13:10:52 【问题描述】:

我的 cron 作业的日志显示如下:

你的“cron”工作

产生以下输出: mv: 无法访问 *SRP* mv: 无法访问 0001LO928365.CSE ... 等等。 但是文件确实确实移动到了所需的位置。 什么可能导致此错误?任何帮助表示赞赏!

【问题讨论】:

我的“猜测”是您在将移动应用于单个文件之前移动了包含文件的目录。你如何生成你正在移动的列表? @DavidC.Rankin - 我只需要将文件移出 - 我将它们(mv + gzip)存档在另一个文件夹中,因为当天要处理的文件总是会出现在这个目录中.我的查询是这样的: cd $from_path mv /*.SRP*/ /*.CSE*/ /*SRP*/ /*CSE*/ /*.xml*/ $to_path (抱歉,我是新来的 - 我不知道'不知道如何在此评论中打印 * 符号,所以我在它之前添加了 /) 【参考方案1】:

抱歉 - 我想通了。

移动命令正在寻找不同的文件类型并移动所有类型。即使文件存在,该命令也会输出错误说明文件未找到。

请参阅下面的测试详细信息:

root@abcd-abcdef:~/movetest/out# ls -lrt
total 5
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile1.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile2.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile3.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile4.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile5.CSE
root@abcd-abcdef:~/movetest/out# cd ../archive
root@abcd-abcdef:~/movetest/archive# ls -lrt
total 0
root@abcd-abcdef:~/movetest/archive# cd -
/home/specuser/movetest/out
root@abcd-abcdef:~/movetest/out# mv *.SRP* *.CSE* *SRP* *CSE* *.xml* ../archive/
mv: cannot access *.SRP*
mv: cannot access *SRP*
mv: cannot access testfile1.CSE
mv: cannot access testfile2.CSE
mv: cannot access testfile3.CSE
mv: cannot access testfile4.CSE
mv: cannot access testfile5.CSE
mv: cannot access *.xml*
root@abcd-abcdef:~/movetest/out# ls -lrt
total 0
root@abcd-abcdef:~/movetest/out# cd -
/home/specuser/movetest/archive
root@abcd-abcdef:~/movetest/archive# ls -lrt
total 5
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile1.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile2.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile3.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile4.CSE
-rw-r--r--   1 root     root           0 Aug 20 13:53 testfile5.CSE
root@abcd-abcdef:~/movetest/archive#*

【讨论】:

以上是关于Cron 作业指示错误 - mv: cannot access <filename> 但文件已移动的主要内容,如果未能解决你的问题,请参考以下文章

是否应该使用“&”指定 linux cron 作业以指示在后台运行? [关闭]

wordpress cron 作业是顺序执行还是并行执行?

运行cron作业时出现网关超时错误

Cron 作业失败 - PHP 版本错误?

Cpanel 不运行我的 cron 作业

无法安装 CRON 作业 [关闭]