aspose file tools*
The moose likes Linux / UNIX and the fly likes calling a java standalone in crontab Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "calling a java standalone in crontab" Watch "calling a java standalone in crontab" New topic
Author

calling a java standalone in crontab

Prashanth Chandra
Ranch Hand

Joined: Dec 07, 2005
Posts: 79
Hi
I am trying to call a java standalone through the crontab. I have written a standalone java program and deployed ths same in /bin. I have written a standalone.sh file and i am calling the java file in that.

standalone.sh(The contents are)
java Update

It works fine if I directly run the file from linux like ./standalone.sh

In my crontab i am calling the standalone.sh as

*/10 8-19 * * Mon-Fri /bin/standalone.sh , which should run every 10 minutes from Monday to Friday. In this same way I have written a servlet(in place of standalone) which works fine.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

cron jobs don't have your full complement of environment variables available because they're not run in a login shell. Just make sure the standalone.sh includes everything it needs to run, and things should work fine -- i.e., path to Java, classpath, LD_LIBRARY_PATH, or whatever else you might need.


[Jess in Action][AskingGoodQuestions]
Don Morgan
Ranch Hand

Joined: Jul 24, 2003
Posts: 84
You can setup a common file with all the environment parameters you need and then source this file from within your shell script to properly set the environment. This is a neat and tidy way of keeping the environment definition in one place and works well if you need to have more than one program running with the same environment variables.


Don Morgan, Founder
www.DeveloperAdvantage.com - FREE Audiobooks for Software Developers
Sarath PS
Greenhorn

Joined: Oct 22, 2004
Posts: 11
try bash --login filename.sh

Which will load all variables !
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You may need to include the following line at the top of your standalone.sh script:

#!/path/to/bash

This is typically needed to make a bash (or other shell) script run as a standalone command, even from the command prompt.

Layne


Java API Documentation
The Java Tutorial
kirti marode
Greenhorn

Joined: May 02, 2006
Posts: 5
I am calling ajava program from a crontab, the entry is something like this

17 16 * * * $HOME/check.sh >>$HOME/test.log 2>&1

where it shd execeute at specfic time and log the o/p of the program to test.log, I could see shellscript and program running but its not dumping the o/p to log file, why so ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling a java standalone in crontab