You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

cron任务提示‘test_cron: command not found’,是否找不到/bin/sh?如何修复?

问题解答

首先明确:不是系统找不到/bin/sh,错误提示/bin/sh: test_cron: command not found的意思是shell找不到test_cron这个可执行文件,而非/bin/sh本身存在问题。

解决方法:

  • 使用test_cron的绝对路径执行:
    cron的环境变量PATH比你登录系统时的PATH精简很多,它无法识别当前目录下的文件,必须写全文件路径。比如你的test_cron放在/home/marlon/目录下,cron任务要改成:
    34 7 * * * /home/marlon/test_cron > /tmp/stdout.log 2> /tmp/stderr.log
    
  • 确保test_cron有可执行权限:
    运行以下命令给文件添加执行权限:
    chmod +x /path/to/test_cron
    
  • (可选)在cron任务中指定PATH:
    如果不想写绝对路径,可以在任务里先设置包含test_cron所在目录的PATH,比如:
    34 7 * * * PATH=$PATH:/path/to/test_cron/directory test_cron > /tmp/stdout.log 2> /tmp/stderr.log
    

内容的提问来源于stack exchange,提问作者marlon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 10:15:39