Solved

How to run java program from cron

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Software required to mount Linux LVM Volume 6 390
making an rpm that just copies the entire project 2 48
Compiling syslinux 6.0.3 from source on Centos 7 3 194
Linux Search 3 66
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 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

12 Experts available now in Live!

Get 1:1 Help Now