Originally posted by arjun rampal:
Hi I have to run a jar file on scheduled time every day after mid night.for this I have written folowwing file cron.sh
now two issue
1) java -jar my.jar where to keep this command so that jar will be executed
2)second I am keeping jar file and script both in same directory /usr/jar.is it o.k
3)script is correct or not ?
#!/bin/sh
CLASSPATH=/usr/jar/myjar.jar:$CLASSPATH
PATH=/usr/java/j2sdk1.4.2_12/jre1.4.2.12/bin:$PATH
export CLASSPATH
export PATH
echo $CLASSPATH
echo $PATH
"chmod +x /user/jar/cron.sh"
1. Use the complete PATH to java and to the jar, and it will be executed.
cron usually doesn't know about PATHs.
2. It is ok in the sense of: will work.
According to the convention, I would put the script to /usr/local/bin, and the jar to /usr/local/lib.
3.
should be sufficient.
I don't understand the last line: "chmod +x /user/jar/cron.sh"
Is this script changing its own permissions? How shall that work?
This has to be done once, not every time the script is run.