Crontab not executing jobs Ubuntu 14.04





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I am trying to run bash script as a cron job every 15 minutes.



The bash script simple calls a Java program. I made an entry in crontab to run the file every 15 minutes and saved it but it would not do anything ?



crontab -e



*/15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh


Run_Cron_Read_Send_CapacityData_To_Graphite.sh



java Cron_Read_Send_CapacityData_To_Graphite  >> Cron_Read_Send_CapacityData_To_Graphite.log









share|improve this question














bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Are you sure "java" is in the PATH? (and I do not mean the users PATH ;-) )

    – Rinzwind
    Sep 17 '14 at 14:10











  • I suggest you redirect std output and std error in order to debug your problem. */15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1

    – Lety
    Sep 17 '14 at 14:17











  • Hi i tried this ' /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/java Cron_Read_Send_CapacityData_To_Graphite ' in the bash script now i get a n error Could not find or load main class ?

    – Marshell
    Sep 17 '14 at 14:52













  • Try to put your cron instructions in /etc/crontab' instead of crontab -e`

    – Harris
    Sep 17 '14 at 15:23


















1















I am trying to run bash script as a cron job every 15 minutes.



The bash script simple calls a Java program. I made an entry in crontab to run the file every 15 minutes and saved it but it would not do anything ?



crontab -e



*/15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh


Run_Cron_Read_Send_CapacityData_To_Graphite.sh



java Cron_Read_Send_CapacityData_To_Graphite  >> Cron_Read_Send_CapacityData_To_Graphite.log









share|improve this question














bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Are you sure "java" is in the PATH? (and I do not mean the users PATH ;-) )

    – Rinzwind
    Sep 17 '14 at 14:10











  • I suggest you redirect std output and std error in order to debug your problem. */15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1

    – Lety
    Sep 17 '14 at 14:17











  • Hi i tried this ' /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/java Cron_Read_Send_CapacityData_To_Graphite ' in the bash script now i get a n error Could not find or load main class ?

    – Marshell
    Sep 17 '14 at 14:52













  • Try to put your cron instructions in /etc/crontab' instead of crontab -e`

    – Harris
    Sep 17 '14 at 15:23














1












1








1








I am trying to run bash script as a cron job every 15 minutes.



The bash script simple calls a Java program. I made an entry in crontab to run the file every 15 minutes and saved it but it would not do anything ?



crontab -e



*/15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh


Run_Cron_Read_Send_CapacityData_To_Graphite.sh



java Cron_Read_Send_CapacityData_To_Graphite  >> Cron_Read_Send_CapacityData_To_Graphite.log









share|improve this question














I am trying to run bash script as a cron job every 15 minutes.



The bash script simple calls a Java program. I made an entry in crontab to run the file every 15 minutes and saved it but it would not do anything ?



crontab -e



*/15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh


Run_Cron_Read_Send_CapacityData_To_Graphite.sh



java Cron_Read_Send_CapacityData_To_Graphite  >> Cron_Read_Send_CapacityData_To_Graphite.log






bash cron






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 17 '14 at 14:06









MarshellMarshell

131135




131135





bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Are you sure "java" is in the PATH? (and I do not mean the users PATH ;-) )

    – Rinzwind
    Sep 17 '14 at 14:10











  • I suggest you redirect std output and std error in order to debug your problem. */15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1

    – Lety
    Sep 17 '14 at 14:17











  • Hi i tried this ' /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/java Cron_Read_Send_CapacityData_To_Graphite ' in the bash script now i get a n error Could not find or load main class ?

    – Marshell
    Sep 17 '14 at 14:52













  • Try to put your cron instructions in /etc/crontab' instead of crontab -e`

    – Harris
    Sep 17 '14 at 15:23



















  • Are you sure "java" is in the PATH? (and I do not mean the users PATH ;-) )

    – Rinzwind
    Sep 17 '14 at 14:10











  • I suggest you redirect std output and std error in order to debug your problem. */15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1

    – Lety
    Sep 17 '14 at 14:17











  • Hi i tried this ' /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/java Cron_Read_Send_CapacityData_To_Graphite ' in the bash script now i get a n error Could not find or load main class ?

    – Marshell
    Sep 17 '14 at 14:52













  • Try to put your cron instructions in /etc/crontab' instead of crontab -e`

    – Harris
    Sep 17 '14 at 15:23

















Are you sure "java" is in the PATH? (and I do not mean the users PATH ;-) )

– Rinzwind
Sep 17 '14 at 14:10





Are you sure "java" is in the PATH? (and I do not mean the users PATH ;-) )

– Rinzwind
Sep 17 '14 at 14:10













I suggest you redirect std output and std error in order to debug your problem. */15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1

– Lety
Sep 17 '14 at 14:17





I suggest you redirect std output and std error in order to debug your problem. */15 * * * * /home/marshell/graphite_cronjobs/Run_Cron_Read_Send_CapacityData_To_Graphite.sh >> /home/marshell/graphite_cronjobs/debug.log 2>&1

– Lety
Sep 17 '14 at 14:17













Hi i tried this ' /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/java Cron_Read_Send_CapacityData_To_Graphite ' in the bash script now i get a n error Could not find or load main class ?

– Marshell
Sep 17 '14 at 14:52







Hi i tried this ' /usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/bin/java Cron_Read_Send_CapacityData_To_Graphite ' in the bash script now i get a n error Could not find or load main class ?

– Marshell
Sep 17 '14 at 14:52















Try to put your cron instructions in /etc/crontab' instead of crontab -e`

– Harris
Sep 17 '14 at 15:23





Try to put your cron instructions in /etc/crontab' instead of crontab -e`

– Harris
Sep 17 '14 at 15:23










1 Answer
1






active

oldest

votes


















0














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





share|improve this answer


























  • It is also possible to put a PATH in crontab ;)

    – Rinzwind
    Sep 17 '14 at 16:10











  • @Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

    – terdon
    Sep 17 '14 at 16:14














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f525192%2fcrontab-not-executing-jobs-ubuntu-14-04%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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





share|improve this answer


























  • It is also possible to put a PATH in crontab ;)

    – Rinzwind
    Sep 17 '14 at 16:10











  • @Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

    – terdon
    Sep 17 '14 at 16:14


















0














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





share|improve this answer


























  • It is also possible to put a PATH in crontab ;)

    – Rinzwind
    Sep 17 '14 at 16:10











  • @Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

    – terdon
    Sep 17 '14 at 16:14
















0












0








0







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





share|improve this answer















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






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 17 '14 at 16:15

























answered Sep 17 '14 at 16:08









terdonterdon

67.7k13139223




67.7k13139223













  • It is also possible to put a PATH in crontab ;)

    – Rinzwind
    Sep 17 '14 at 16:10











  • @Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

    – terdon
    Sep 17 '14 at 16:14





















  • It is also possible to put a PATH in crontab ;)

    – Rinzwind
    Sep 17 '14 at 16:10











  • @Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

    – terdon
    Sep 17 '14 at 16:14



















It is also possible to put a PATH in crontab ;)

– Rinzwind
Sep 17 '14 at 16:10





It is also possible to put a PATH in crontab ;)

– Rinzwind
Sep 17 '14 at 16:10













@Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

– terdon
Sep 17 '14 at 16:14







@Rinzwind yes but personally I find using full paths better. In any case they're needed for the input and output files here. Still, I added an example of setting the path in the crontab.

– terdon
Sep 17 '14 at 16:14




















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f525192%2fcrontab-not-executing-jobs-ubuntu-14-04%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

GameSpot

connect to host localhost port 22: Connection refused

Getting a Wifi WPA2 wifi connection