Connecting Tech Pros Worldwide Forums | Help | Site Map

proble in running shell script in cron

Newbie
 
Join Date: Oct 2007
Posts: 25
#1: Apr 12 '08
i have a java file which i am running through shell script.

the syntax that i have used is

#! /bin/bash

javac Copy.java




#home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java Copy
/usr/bin/java Copy




this is my shell script
when i run it in terminal with command called ./runcopy.sh
it works fine



but when i run this shell script in cron it is not working.problem with java.lang


my cron is here:

1 * * /home/log/sari/./runcopy.sh


runcopy is shell script name.


help me out



ashitpro's Avatar
Expert
 
Join Date: Aug 2007
Posts: 389
#2: Apr 12 '08

re: proble in running shell script in cron


Quote:

Originally Posted by smitanaik

i have a java file which i am running through shell script.

the syntax that i have used is

#! /bin/bash

javac Copy.java




#home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java Copy
/usr/bin/java Copy




this is my shell script
when i run it in terminal with command called ./runcopy.sh
it works fine



but when i run this shell script in cron it is not working.problem with java.lang


my cron is here:

1 * * /home/log/sari/./runcopy.sh


runcopy is shell script name.


help me out

redirect the output in some file..and see what it gives..
may be you'll get the answer

1 * * /home/log/sari/./runcopy.sh > /tmp/a.txt
docdiesel's Avatar
Moderator
 
Join Date: Aug 2007
Location: Munich
Posts: 289
#3: Apr 12 '08

re: proble in running shell script in cron


Hi,

once I had a similar problem with a DB2 script. The trick is that when working in interactive shell all env. variables you need for Java, DB2, or whatever, are set, while they may not be set for cron.

Try to set your environment by sourcing your .profile script:

Expand|Select|Wrap|Line Numbers
  1. 1 * * * * . ~/.profile ; /home/log/sari/./runcopy.sh >~/runcopy.log
May be you need to source /etc/profile instead. Depends on where the Java variables you need are stored.

Regards,

Bernd
Reply