There are two possible issues here. First of all, cron runs jobs in a special shell which does not read your personal $PATH. If java
is not in /usr/bin
or /bin
, it will not be available to cron. From man 5 crontab
:
Several environment variables are set up automatically by the
cron(8) daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are
set from the /etc/passwd line of the crontab's owner.
PATH is set to "/usr/bin:/bin". HOME, SHELL, and PATH may
be overridden by settings in the crontab; LOGNAME is the user that
the job is running from, and may not be changed.
So, use the full path to java
instead. The next issue is that your bash script calls java on a file with a relative path. It assumes that the script will be launched from the same directory as the java file. Again, this is not the case. So, always use absolute paths for your scripts if you want them to run as expected by cron:
/path/to/java /path/to/Cron_Read_Send_CapacityData_To_Graphite >> /path/to/Cron_Read_Send_CapacityData_To_Graphite.log
Alternatively, you can set the $PATH
in the crontab itself:
PATH=$PATH:/opt/bin
*/15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh
*/15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1
/etc/crontab' instead of
crontab -e`