我使用cron来定期运行PHP脚本:运行cron作业里面的exec()函数找不到命令
*/5 * * * * php /path/to/my/script.php
里面的PHP脚本我有一个运行的exec命令节点:
$command_str = 'node my_node_script.js';
exec($command_str, $output_arr, $error_res);
一切工作在命令行很好,但不是通过cron。所以,我记录的输出,并且我收到以下错误:
sh: node: command not found
这究竟是为什么,以及如何解决呢?
查看[“通过cron运行脚本时找不到命令”](http://askubuntu.com/questions/47800/command-not-found-when-running-a-script-via-cron ) - 我会将其标记为一个复制品,但它位于不同的网站上。 –