[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to run java program from cron

Posted on 2006-11-21
2
Medium Priority
?
1,277 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 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