找不到从cronjob命令运行的bash脚本 [英] bash script running from cronjob command not found

查看:102
本文介绍了找不到从cronjob命令运行的bash脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的crontab如下:

my crontab is as follows:


SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
01 04 * * * root /home/sphinx_scripts/daily_update_index.sh

daily_update_index.sh如下:

daily_update_index.sh is as follows:


indexer  --rotate xxx

现在,如果我从任何地方(作为根用户)运行/home/sphinx_scripts/daily_update_index.sh,它都可以正常工作。但是我每天从cron作业收到电子邮件,说找不到命令索引器。索引器的完整路径是/ usr / loca / bin / indexer。为什么会出现这样的错误?

now if I run /home/sphinx_scripts/daily_update_index.sh from anywhere(as root), it works fine. But I get emails daily from cron job saying "command indexer is not found". the full path of the indexer is /usr/loca/bin/indexer. Why would I get such an error?

推荐答案

问题是索引器不在路径上。您说它是/ usr / loca / bin / indexer amd PATH = / sbin:/ bin:/ usr / sbin:/ usr / bin

为了解决这个问题,我会将整个索引器路径放​​在daily_update_index.sh中,或者将/ usr / local / bin添加到daily_update_index.sh中的路径

The issue is that indexer is not on the path. You say it is /usr/loca/bin/indexer amd PATH=/sbin:/bin:/usr/sbin:/usr/bin
To fix this I would put the whole path to indexer in daily_update_index.sh or add /usr/local/bin to the path in daily_update_index.sh

这篇关于找不到从cronjob命令运行的bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆