pato.llaguno
pato.llaguno

Reputation: 741

crontab not running java

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?

Upvotes: 0

Views: 605

Answers (1)

Grim
Grim

Reputation: 2026

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.

Upvotes: 2

Related Questions