Solved

How to run java program from cron

Posted on 2006-11-21
2
1,246 Views
Last Modified: 2012-05-05
I thought it would be just like anything else, but for some reason my java program returns a non-zero return code when run from cron. When run from command line it works fine.

This is my code that excutes the java program.

JAVADIR=/usr/java/jdk1.5.0_06/bin

CLASSPATH=/test/hstaload:/opt/jboss-4.0.3SP1/server/default/lib/postgresql-8.1-404.jdbc3.jar:/test/hstaload/alturalibCompile.jar:/test/hstaload/HstaLoad.jar
export CLASSPATH
export JAVADIR

$JAVADIR/java HstaLoadCeridianPay >>$JOBLOG
CONDCODE=$?
0
Comment
Question by:mhunts
2 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17993491
What do you get in log file? Any information to why it failed? It has to be envirnment related. To make sure add your .profile/.bashrc/.cshrc (or whatever is your shell startup script) to this script. If the program works fine in cron it is env related.

. /home/user1/.profile
JAVADIR=/usr/java/jdk1.5.0_06/bin

You could either leave the profile there in your script or add its content one by one until you find out which one makes your program run fine from cron.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17993761
The problem is that $JOBLOG isn't defined, so effectively, you're running the command

$JAVADIR/java HstaLoadCeridianPay >>

which will give you a syntax error.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now