Solved

How to run java program from cron

Posted on 2006-11-21
2
1,262 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
A "Helper" for python 2 102
Debian 3.16.7 3 152
Automating a set of commands run on linux 7 100
Linux Hanging with disable Error Output 4 89
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 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