By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,822 Members | 729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,822 IT Pros & Developers. It's quick & easy.

proble in running shell script in cron

P: 26
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
Apr 12 '08 #1
Share this Question
Share on Google+
2 Replies


ashitpro
Expert 100+
P: 542
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
Apr 12 '08 #2

docdiesel
Expert 100+
P: 297
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
Apr 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.