Solved

How to run java program from cron

Posted on 2006-11-21
2
1,269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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