File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Run a cron after tomcat startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Run a cron after tomcat startup" Watch "Run a cron after tomcat startup" New topic

Run a cron after tomcat startup

naveen kk

Joined: Nov 07, 2007
Posts: 4
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

Joined: Mar 22, 2005
Posts: 42965
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?
I agree. Here's the link:
subject: Run a cron after tomcat startup
jQuery in Action, 3rd edition