crontab not running java

折月煮酒 提交于 2019-12-12 03:37:54

问题


I have a .jar which I can run perfectly via the command line.

I need this to be running continuosly every 5 mins, so i did crontab -e where I added this line

*/5 * * * * java -jar /var/www/java/executable.jar

if I go

grep CRON /var/log/syslog

I do see where the job was executed, but it never was since I have a logger inside the java file and the first thing it does is append to the logger the time, which is not doing so.

What can be the possible error?


回答1:


The most common error is that the environment-variables not bound and

  1. java is not in path
  2. JAVA_HOME is not set.

Try

*/5 * * * * java -jar /var/www/java/executable.jar > /var/log/javacron.log 2> /var/log/javacron-err.log

and inspect the /var/log/javacron.log-file for more informations.



来源:https://stackoverflow.com/questions/37668434/crontab-not-running-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!