Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-09-2010, 11:07 AM   #1
LQ Newbie
Registered: Jul 2010
Posts: 6

Rep: Reputation: 0
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!
Old 07-09-2010, 05:01 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
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 ...

Old 07-29-2010, 05:47 AM   #3
LQ Newbie
Registered: Jul 2010
Posts: 6

Original Poster
Rep: Reputation: 0

sorry i was away for 2 weeks, the code is stored as above
Old 07-29-2010, 06:04 AM   #4
Registered: May 2002
Location: Thorverton, Near Exeter, Devon, England
Distribution: Ubuntu 10.04 (used to be Red Hat 7.1, then Red Hat 9, then FC 2, FC 5, FC 6, FC 9 and Ubuntu 8.04)
Posts: 105

Rep: Reputation: 16
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.
Old 07-29-2010, 07:58 AM   #5
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

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

props.load(new FileInputStream(""));
When you run it at the terminal; I assume you cd into the directory where 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/ - rather explicitly specify the location in your code. Alternately there are build tools out there that will build your properties file into your JAR.
Old 08-02-2010, 08:12 AM   #6
LQ Newbie
Registered: Jul 2010
Posts: 6

Original Poster
Rep: Reputation: 0

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

thanks guys


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] script not running via crontab, run's fine manually astroboiii Linux - Software 10 02-08-2010 11:36 PM
UBUNTU Intrepid Gampad Dpad wont work, works fine in jcalibrator zonemikel Linux - Hardware 1 03-22-2009 07:42 PM
When i try to play gmod or half life, it runs great, but the controls wont t-bone09 Linux - Games 11 12-23-2008 03:05 AM
Cron Job only runs when it is manually started sinister1 Linux - General 4 02-25-2008 09:35 AM
script runs fine from a command line, but doesn't work from cron? kleptophobiac Linux - Software 5 05-03-2004 05:14 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:46 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration