• 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

Running Java Program as Cron job.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The above is the content of my .sh file which i have configured in crontab as below.


It is creating an empty file "ipmonitor.log". But, the java program is not running.


And, where can we find the logs for cron jobs if my app is throuwing error.


Sereking help on this
Thank you..

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nisanth,
Welcome to CodeRanch!

I typically redirect the output in the crontab file itself.
* * * * * /nav/apps/jobs/runJobs.sh >> /nav/apps/jobs/runJobs.log

I'm not sure since I don't use it, but I believe the default logs are in /var/logs/cron or a system log in that same file.
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The crontab stuff runs in a rudimentary environment: .profile is not executed.
Do you take care of the standard error? Is java on the PATH?
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cron typically has its own logfile (my distro uses /var/log/cron) and it also may email logs to the cron job owner.

The most important thing to realize when setting up for cron operation is that the cron job itself will not be executing in the warm, comfortable, friendly environment that you'd have when executing the same function as a normal user. So it's best to be careful about what environmental settings you assume are in effect, don't assume you know what your current directory is until (/if) you set it, and access everything via absolute paths. Especially scripts and programs.

In your specific case, you might also be running afoul of the normal mechanisms that keep the /tmp directory clean. I recommend that any log you want to be sure stays around is written to a less volatile location. For system-level cron tasks, the recommended place to put logs is under /var/log. If your service produces more than 1 logfile, make a subdirectory under /var/log to put them all in.
 
reply
    Bookmark Topic Watch Topic
  • New Topic