CRON 作业错误 /usr/bin/env: 节点: 没有这样的文件或目录

Ter*_*nce 0 shell cron node.js

我在 cron 作业中收到此错误

 /usr/bin/env: node: No such file or directory
Run Code Online (Sandbox Code Playgroud)

所以我这样做了

 */10 * * * * . $HOME/.bashrc sh /path/to/cronjob.sh
Run Code Online (Sandbox Code Playgroud)

在我的 cron 工作中

但随后它给了我这个错误

 /etc/cron.daily/man-db:
 /usr/bin/mandb: can't set the locale; make sure $LC_* and $LANG are correct
Run Code Online (Sandbox Code Playgroud)

小智 5

当您直接在 cron 条目中执行此操作时: . $HOME/.bashrc您实际上是要求用户 cron 设置其环境,并且很可能它没有定义区域设置。

您应该在设置 bash 指令后直接在脚本中设置环境:

    #!/bin/bash
    . $HOME/.bashrc
    echo Hello World
Run Code Online (Sandbox Code Playgroud)

.bash_profile如果先配置一下.profile再加载就更好了.bashrc