Script in cron cannot find command
Cron doesn't run with the same environment as a user. If you do the following you will see what I mean:
type env
from your terminal prompt and make note of the output.
Then set a cron job like this and compare it's output to the previous:
*/5 * * * * env > ~/output.txt
You will find that the issue is likely because crontab
does not have the same PATH
variable as your user. As a solution to this you can (from your postgres user) echo $PATH
and then copy the results of that to the first line of your crontab (something like this)
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/jbutryn/.local/bin:/home/jbutryn/bin
Or if you want to be more specific you can simply add the following:
PATH=$PATH:/usr/local/bin
However I normally always put my user's PATH in crontab because I haven't yet heard a good reason not to do so and you will likely run into this issue again if you don't.