LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab wont work - runs manually fine (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-wont-work-runs-manually-fine-818922/)

alabama78 07-09-2010 10:07 AM

crontab wont work - runs manually fine
 
Any idea, 2 days ago everything was fine

I then added a properties file to my java program and cant get the program to run.

runs fine when ran script manually from root, however does not run through crontab any more.

do the property files need adding to root too or can they run from the same place as my programs?

please help!

Tinkster 07-09-2010 04:01 PM

Hi, welcome to LQ!

What does the invocation on the command-line look like,
what does it look like in crontab? Please post both in
code tags ... [ CODE ] [ /CODE ] ... w/o the spaces between
the brackets and the words CODE and /CODE ...


Cheers,
Tink

alabama78 07-29-2010 04:47 AM

http://www.linuxquestions.org/questi...y-fine-822645/

sorry i was away for 2 weeks, the code is stored as above

hairysocks 07-29-2010 05:04 AM

Is it because when you run the shell script you are in a different directory to the home directory for the user for the crontab running of the script? Maybe you should specifically cd to the directory at the start of your script.

You could add something to your Java application to list all the System properties - that could give you more information to work with.

alli_yas 07-29-2010 06:58 AM

Post #4 is correct. The line below is your problem:

Code:

props.load(new FileInputStream("test10.properties"));
When you run it at the terminal; I assume you cd into the directory where test10.properties is located? Then when you execute the application should find the properties file?

When run from the root crontab; the application will look for /root/test10.properties - rather explicitly specify the location in your code. Alternately there are build tools out there that will build your properties file into your JAR.

alabama78 08-02-2010 07:12 AM

thanks
 
thats perfect i changed to the //home exact location in my java and now works.

strange it didnt pick up the file though as it was in my .jar build as test.properties

thanks guys


All times are GMT -5. The time now is 03:59 PM.