Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run a cron after tomcat startup

 
naveen kk
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have set of web applications which i am deploying in to tomcat. In one war file, i have cron which will run for every 10 seconds. My idea is that cron has to run for every 10 seroncds after complete startup of tomcat server.

Currently the war which is having the cron is getting invoked after 10 seconds before the deployment of all wars in to tomcat.

is there any way to call cron only after complete server startup?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be clear about terminology: "cron" is a Unix/Linux system tool; it has nothing to do with web apps. I think what you're talking about is a scheduled task started by the web app.

Whenever I hear about scheduled tasks in web apps, my first question invariably is: why is it part of the web app, and not an actual cron job?

In this particular case, the next question is: why does it need to run after the server is finished starting up, instead of after the web app it's part of having finished starting up?

And lastly: if it's really important that it not start up until every single web app has started, why not start it with an X minutes delay (X being the time when you can be sure that all web apps have started), or put in place a synchronization mechanism that waits until all web apps have started?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic