Cron: command not found
From FVue
Problem
When executing a bash file via cron, I get this error:
dar: command not found
Solution
Within the crontab file, specify PATH including /usr/local/bin:
PATH=/usr/bin:/bin:/usr/local/bin
Explanation
I recently compiled dar, which made dar move from /usr/bin to /usr/local/bin. (You can find out the location from where a program is started by typing which name-of-program.)
Unix Crontab - setting up cron jobs using crontab - Environment:
- "cron invokes the command from the user's HOME directory with the shell, (/usr/bin/sh).
- cron supplies a default environment for every shell, defining:
HOME=user's-home-directory LOGNAME=user's-login-id PATH=/usr/bin:/usr/sbin:. SHELL=/usr/bin/sh
Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.
Journal
$> which dar # Shows me where the command is located /usr/local/bin/dar $> crontab -e # Added 'set' to crontab to reveal settings during cron
The 'set' command within cron shows me:
PATH=/usr/bin:/bin PS4='+ '
The PATH doesn't contain /usr/local/bin so that's why dar can't be found.
Advertisement