3
votes

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 is as follows:

indexer  --rotate xxx

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?

2

2 Answers

7
votes

The issue is that indexer is not on the path. You say it is /usr/local/bin/indexer and you have 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

0
votes

I'm working on an AWS EC2 instance and for me the issue was that I used pscp to transfer my .sh file from my Windows 10 machine, and the file's line endings were incompatible. So I used sudo apt-get install dos2unix and then used dos2unix to convert the file to the correct format.