Cpanel, Cron and Java Classpaths

fiftythree

Registered
Jan 26, 2007
3
0
151
Hey, I'm new to Cpanel and having a hell of a time with getting my Java to run on the Cron scheduler.

The only options from the interface are to insert a job, and send an email to somebody.
So if I need to add PATH or CLASSPATH information so that things will run correctly, how do you do that !!!!????

I have set it up and can run it through SSH with that user after modifying that users .bashrc file, but that is only good if you're running stuff through the SSH.
 

appservermgr

Member
Feb 16, 2007
20
0
151
Hi,

You should create a script file for your cron job.
In the script file you would include the command of course and in addition set the
CLASSPATH, JAVA_HOME and any other variables like so:

EXPORT CLASSPATH=$CLASSPATH:./lib/lib1jar:./lib/lib2.jar
EXPORT JAVA_HOME=/usr/java/jdk_version
 

fiftythree

Registered
Jan 26, 2007
3
0
151
Interestingly enough, I've been trying that, but without success.
Originally I had the following:

Code:
#!/bin/bash

export JL=~/java/lib
export CLASSPATH=$CLASSPATH:~/java:$JL/pg73jdbc3.jar:$JL/edtftpj-1.4.5.jar:$JL/mail.jar:$JL/ftp.jar
export PATH=/home/mlsupdat/java:/home/mlsupdat/java/bin:$PATH

java myjafafile > logfile
all the "exports" are included in the users .bashrc file and allow the java to run correctly.

and then I added (after your email)

Code:
export JAVA_HOME=/usr/local/jdk/bin/
but I'm still coming up with the error:

libgcj-java-placeholder.sh

This script is a placeholder for the /usr/bin/java​
 

fiftythree

Registered
Jan 26, 2007
3
0
151
Well, I figured it out.


I needed the following (which is included in the standard .bashrc file)

Code:
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

I now see, finally, that THIS is the global bashrc file.
Can you tell me what that part of the script actually does?
I'm guessing, if it isn't loaded, it loads it...


Thanks for the quick reply.


Herb
 
Last edited: