【问题标题】:Why doesn't my little cron job find the shell command?为什么我的小 cron 作业找不到 shell 命令?
【发布时间】:2022-10-25 22:50:18
【问题描述】:
 34 7 * * * test_cron > /tmp/stdout.log 2> /tmp/stderr.log

我的可执行文件“test_cron”包含:

echo "Test cron job ..."

now=$(date)
echo "Cron job update completed at $now"

但是当它执行时,标准错误如下:

tmp % tail /tmp/std*           
==> /tmp/stderr.log <==
/bin/sh: test_cron: command not found

==> /tmp/stdout.log <==

这是否意味着它找不到/bin/sh?如何解决?

【问题讨论】:

  • 不,恰恰相反。 sh 找不到您的脚本。

标签: cron


【解决方案1】:

您可以检查的几件事

  1. test_cron 是否有可执行标志?如果没有,您可以在脚本所在的目录中运行以下命令。
    chmod +x test_cron
    
    1. test_cron 脚本是否存在于$PATH 中?

    PS:我建议在您的 cron 配置中写入 test_cron 脚本的绝对路径。在这种情况下,您不需要将脚本添加到您的 $PATH

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 2010-09-06
    • 2015-05-18
    相关资源
    最近更新 更多