proble in running shell script in cron

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smitanaik
    New Member
    • Oct 2007
    • 26

    proble in running shell script in cron

    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
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    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

    Comment

    • docdiesel
      Recognized Expert Contributor
      • Aug 2007
      • 297

      #3
      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:

      Code:
      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

      Comment

      Working...