• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling a java standalone in crontab

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try bash --login filename.sh

Which will load all variables !
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic