The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Java to tuxedo through cron charu Shell Programming and Scripting 4 1 Week Ago 11:19 PM
call constructor of java class in script thebladerunner Shell Programming and Scripting 1 10-21-2008 12:23 PM
PHP or Java Class Code Generator 1.1.0 (Default branch) iBot Software Releases - RSS News 0 02-08-2008 09:50 AM
How to call Java class from ksh jyotib Shell Programming and Scripting 3 01-14-2008 11:40 AM
S-058: HP-UX Running Java JRE and JDK iBot Security Advisories (RSS) 0 12-24-2007 06:40 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-25-2005
Registered User
 

Join Date: Oct 2005
Posts: 1
Running java class with a cron

Hello everybody,

I have a problem about running a java class with a cron :

I have Cron.txt file which has :
0,5,10,15,20,25,30,35,40,45,50,55 * * * * CronJava.txt

I have CronJava.txt wihich has :
cd ias/j2ee/SapAktarim/applications/SapAktarim/SapAktarim/WEB-INF/classes/;java -classpath $CLASSPATH main.SapAktarim

When cron works I get "help of java command" from my mail.

if i do it manually, cd to path and type
java -classpath $CLASSPATH main.SapAktarim it works without a problem.

When I place it in a cron, I get this situation.

Maybe cron can't see my user classpath info.

When I try a sipmle class which only system.out.println("Hello") it works with the cron ...?


I am new on Unix...

Helps appreciated...

Thanks a lot
Reply With Quote
Forum Sponsor
  #2  
Old 10-25-2005
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,493
You might try printing the $CLASSPATH shell variable in your shell script to see if all is OK.
Reply With Quote
  #3  
Old 10-26-2005
Registered User
 

Join Date: Aug 2005
Location: India
Posts: 17
Hai,

in ur java class ur specfying some thing to print on console but may be there may be no console
opened to print ur s.o.println from crontab u can't start application which have GUI interface if u really want to start up like then install screen.rpm and in the crontab before the script calling specify it as

25 * * * * root screen -d -m myclass.java

Reply With Quote
  #4  
Old 10-26-2005
Registered User
 

Join Date: Jul 2005
Location: Oak Park, IL
Posts: 100
In CronJava.txt do this:

echo $CLASSPATH > /tmp/cronout

Wait a while. While you're waiting, do this:

echo $CLASSPATH

Compare that to the contents of /tmp/cronout. Are they the same? If not, do this ONCE:

echo "#!/bin/sh" > /tmp/tmpfile
echo "CLASSPATH=$CLASSPATH" >> /tmp/tmpfile
echo "export CLASSPATH" >> /tmp/tmpfile
cd /to/directory/where/your/CronJava.txtfile/is
cat CronJava.txt >> /tmp/tmpfile
# If you get any errors during the above actions, STOP. Try to fix them. Retry commands. If everything looks ok, then,
cp /tmp/tmpfile CronJava.txt

You should be all set.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0