【问题标题】:Condition supplied in cron job returns "No such file or directory"cron 作业中提供的条件返回“没有这样的文件或目录”
【发布时间】:2011-05-26 23:32:13
【问题描述】:

我正在尝试在 cron 作业中执行此代码:

a=`/home/mailmark/node/bin/forever list`; if [ "$a" == "No forever processes running" ]; then forever start /api.js; fi

有问题的文件“永远”包含这个 shebang:

#!usr/bin/env node    

它返回这个响应:

/usr/bin/env: node: No such file or directory

但我在 .bashrc 文件的最后一行有这段代码:

export PATH=/home/mailmark/node/bin:$PATH

我应该怎么做才能让我的 cron 工作?

【问题讨论】:

    标签: bash cron redhat


    【解决方案1】:

    使用节点的完整路径:

    #!/usr/bin/env /home/mailmark/node/bin/node
    

    【讨论】:

      【解决方案2】:

      cron 不在“登录 shell”中运行,因此不会加载 .bash_profile.bashrc

      【讨论】:

      • 如何在 mac os x 上修复?没有 .bashrc 或 .bash_profile :(
      【解决方案3】:

      . $HOME/.bashrc 添加到您的 cron 作业的开头。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-06-19
        • 2014-05-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-02
        • 2013-09-26
        相关资源
        最近更新 更多