This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a java standalone in crontab

 
Prashanth Chandra
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don Morgan
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sarath PS
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try bash --login filename.sh

Which will load all variables !
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
kirti marode
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic