|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Proble in running shell script in cron
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 |
|
#2
|
|||
|
|||
|
Quote:
Your cron entry does not need - nor want - the ./ that you use from a command line. The ./runcopy.sh simply tells the shell to run the command from "here". That needs to be done since "here" is not always in your path - and that is a good thing. So - in the cron entry you specify the full path to the script without the ./ prefix. 1 * * /home/log/sari/runcopy.sh Cheers |
|
#3
|
|||
|
|||
|
The dor may be a red herring, but it would be good to get rid of. I would further suspect that the PATH is not set up when being run via cron - you get a very basic PATH by default.
__________________
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer" - Bruce Graham |
|
#4
|
|||
|
|||
|
#! /bin/bash
javac CopyFile.java /usr/bin/java CopyFile this is my shell script.when i call this script from terminal works fine.but through cron it gives me error saying exception i think it is not able to find the files that i have imported such as import java.io.*; import java.util.*; import java.lang.*; import java.text.*; import java.io.File; help me out |
|
#5
|
|||
|
|||
|
When I said PATH, I should have said your general environment!
Try putting a source (the . command) of your .profile (or .bashrc or whatever) at teh top of the script. |
|
#6
|
|||
|
|||
|
#!/bin/bash
CLASSPATH=. #CLASSPATH=${CLASSPATH}:${INSTALL_PATH}home/squidlog/CopyFile.java CLASSPATH=${CLASSPATH}:${INSTALL_PATH}usr/java/latest/lib/*.jar javac CopyFile.java echo "CLASSPATH=$CLASSPATH" #home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile /usr/bin/java CopyFile i tried setting classpath still i have problem |
|
#7
|
|||
|
|||
|
Out of interest, where is INSTALL_PATH defined?
|
|
#8
|
|||
|
|||
|
#! /bin/bash
CLASSPATH=.:usr/java/latest/lib/*.jar javac CopyFile.java echo "CLASSPATH=$CLASSPATH" #home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile /usr/bin/java CopyFile i tried likre this but still not working |
|
#9
|
|||
|
|||
|
I really hate java ...
I still reckon it's your environment. Humour me? In your script, before you call the java put an env command, so your current environment is displayed. Run it by hand, then run it via cron and see what the difference is. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > Proble in running shell script in cron |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|