Computing.Net > Forums > Linux > crontab problem

crontab problem

Reply to Message Icon

Original Message
Name: karmaker
Date: May 21, 2007 at 20:50:19 Pacific
Subject: crontab problem
OS: linux
CPU/Ram: 222
Model/Manufacturer: linux
Comment:

Hi,


I am new to UNIX Env.I have a batch file which has the following lines.

#!/bin/sh
PATH=$PATH\:/var/shine/scripts/ListUsersJob ; export PATH
/usr/java/j2sdk1.4.2_10/bin/javac -classpath activation.jar:mail.jar:. ListUsersJob.java
/usr/java/j2sdk1.4.2_10/bin/java -cp activation.jar:jtds-1.2.jar:mail.jar:. ListUsersJob


The above batch job runs well when i try to run it in the same directory (ie.,

/var/shine/scripts/ListUsersJob), but when i set this batch job as a cron, it is giving me the

following error when i checked my mail in UNIX env.

mail content _______________________________________________________________

To: jboss@localhost.localdomain
Subject: Cron <> /var/shine/scripts/ListUsersJob/runJob.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/opt/jboss-4.0.3SP1>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=jboss>
X-Cron-Env: <USER=jboss>

error: cannot read: ListUsersJob.java
1 error
Exception in thread "main" java.lang.NoClassDefFoundError: ListUsersJob

______________________________________________________________________________


The following is my crontab setting

[jboss@msapp01s ~]$ crontab -l
05 11 * * * /var/shine/scripts/ListUsersJob/runJob.sh


I would appreciate your help in solving this pr



Report Offensive Message For Removal


Response Number 1
Name: thepubba1
Date: May 22, 2007 at 10:58:11 Pacific
Subject: crontab problem
Reply: (edit)

Export your java variables (JAVAHOME for example) in your script. Most likely, these variables are set in your login shell via the .profile, but they are not set when the job is executed from the crontab.


Report Offensive Follow Up For Removal

Response Number 2
Name: KenJackson
Date: May 25, 2007 at 04:45:20 Pacific
Subject: crontab problem
Reply: (edit)

The current directory for cron is not your directory, so put this line in runJob.sh before you call javac or java:

cd /var/shine/scripts/ListUsersJob


Why I prefer GNU/Linux


Report Offensive Follow Up For Removal

Response Number 3
Name: thepubba1
Date: May 30, 2007 at 06:32:27 Pacific
Subject: crontab problem
Reply: (edit)

Ken:

The java error indicates the process is not finding the java class files. It is an environment issue, not a PATH issue. If JAVAHOME is not set, the " Exception in thread "main" java.lang.NoClassDefFoundError: ListUsersJob" error occurs. There are also other java variables that might need to be set. I'll bet that they are set in his .profile, which is why his process executes from a command line.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: crontab problem

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge