cron and its limited enviroment….
If you ever see this from a crron script :
$FILE_RUN_FROM_CRON: line $LINE: $COMMAND: command not found Error: (CLI:043) Invalid shell command syntax. |
Then you likely:
- Forgot to setup a proper PATH in your script
- You declared a variable but didnt use it or the file isnt in the setup PATH (ie set VAR1=/usr/local/bin/crazybinary but then just used crazybinary in the script)
- messed up something in a /etc/profile.d/ file
- Likely more but ….
I run across this from time to time due to typos I make and thought the internet at large might benefit. Don’t forget cron has a limited environment by default ! Lots of ways on the net to fix this but this error was a little more hidden so I thought I would help it get some google love! For those that wanted to know about how different the cron environment is here is a (near) default RHEL6 environment:
SHELL=/bin/sh
MAILTO=
USER=root
PATH=/usr/bin:/bin
PWD=/root
LANG=en_US.UTF-8
SHLVL=1
HOME=/root
LOGNAME=root
_=/bin/env
Quite Spartan !