00 00 * * * /home/username/run.sh >> /home/username/log 2>&1
source /home/username/.bashrc java
When crontab job is triggered, I got this error in the log:
/home/username/run.sh: 1: /home/username/run.sh: java: not found
However, java path is set in /home/username/.bashrc, so I was expecting sourcing should set the java path:
I know I can fix it by:
export PATH="/usr/local/jdk1.8.0_231/bin:$PATH" java
But why sourcing .bashrc is not enough? What environment variables does crontab have exactly and what does source .bashrc do exactly (so that crontab doesn't take it into account)?