Hi I have to run cron job for which a.sh file is below. jar file is in /home/wasadmin/jar.Both a.ct and a.sh is also in same jar folder now issue is if i run this jar through cron nothing is happening as application is not able to get application properties. but if i run this command from /home/wasadmin/jar folder it is running perfectly(means not through cron). any idea as i need to run through cron /usr/java/j2sdk1.4.2_12/bin/java -jar /home/wasadmin/jar/A.jar any idea.
One possible solution: keep in mind that the cron environment is setup different from a user's normal environment, which is probably why that you are able to successfully execute the shell script as a user as opposed to cron executing the same script.
I would look into modifying your shell script and/or jar file by implementing full paths to files/executables and/or exporting environment variables in your a.sh script. [ October 20, 2006: Message edited by: Craig Jackson ]
You might find it easiest to setup your pathing and current directory as the first commands in your script. For example, add the following to the script..
cd /home/wasadmin/jar # Change current working directory to where the files are stored. While setting the PATH environment variable should cover this, if you reference any local files within subsequent scripts this adds some safety.
PATH=$PATH:/home/wasadmin/jar # Setup the PATH to include the working directory. In this way, the line beginning with 'a.ct' should pick up the appropriate file.
As you can run the a.ct properly when running this logged in directly, it's not a case of permissions.
Joined: Jul 08, 2005
Hi i changed like that
i used this in script #!/bin/sh cd /home/wasadmin/jar /usr/java/j2sdk1.4.2_12/bin/java -jar /home/wasadmin/jar/A.jar echo hello
but now in mail I am getting nothing except hello. and jar is not working as expected from this script but from command line (/usr/java/j2sdk1.4.2_12/bin/java -jar /home/wasadmin/jar/A.jar)its working. I dont know relavent or not but one application.properties is in jar file which is used by application.
Joined: Jul 08, 2005
means if my current working directory is /home/wasadmin/jar and from here i run command it works but though cron not