tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiang, Peiyun" <Peiyun.Ji...@nrc-cnrc.gc.ca>
Subject RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
Date Tue, 21 Dec 2004 17:28:32 GMT
You may use a scheduler to schedule your tasks to run every 30 minutes. 

http://www.theserverside.com/blogs/printfriendly.tss?id=QuartzSchedulerInJ2E
E
http://www.quartzscheduler.org/quartz/. 

Peiyun

-----Original Message-----
From: Allistair Crossley [mailto:Allistair.Crossley@QAS.com]
Sent: December 21, 2004 12:21 PM
To: Tomcat Users List
Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30


myself and ben have suggested the most appropriate methods for doing this.
Ben mentions WGET http://www.gnu.org/software/wget/wget.html which can be
added to a *basic* script hooked up to a cron with an interval of whatever
you like.

you really ought to get rid of threads and thread sleeps inside web
application code.

Allistair.

> -----Original Message-----
> From: Jorge Sopena [mailto:jsopena@sidsa.es]
> Sent: 21 December 2004 17:15
> To: Tomcat Users List
> Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
> 
> 
> Hi,
> I'm having a similar problem in my application.
> I've got several servlets called by the users. Every requets 
> save some 
> information in DB, that has to be sent to another server 
> later and in a 
> compress format.
> So I need sth similar toShilpa is asking, a process which 
> runs every  X 
> minutes to recover the information and send it to the Server.
> 
> My solution to this problem was to implement a 
> "ServletContextListener" 
> inside Tomcat.
> When Tomcat starts my application the "contextInitialized" method is 
> called, and then a thread is started to do the task explained above.
> I use "Thread.sleep(step)" to wait for the next execution.
> 
> I didn't find anyway to set a timer for a servlet, and I 
> didn't like the 
> option of creating an external script .
> 
> Any other  suggestions to solver this problem?
> 
> Thanks
> 
> Jorge
> 
> 
> Ben Souther wrote:
> 
> >On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote:
> >  
> >
> >>no, and I believe doing so it bad practice. use some OS 
> controlled timer like cron to issue a HTTP call to your 
> servlet. I once wrote a shell script that calls a http 
> address on the local machine but cannot remember how ;) if 
> you are using oracle then you can setup this timer thread 
> inside the database itself. don't add a thread into your web 
> application.
> >>
> >>    
> >>
> >
> >I concur. It's certainly possible to write a treaded java object that
> >fires a command every so often but there would be no point in making
> >that object a servlet (servlets exist to answer client requests). 
> >It's also, IMHO, more aggravation than it's worth to manage your own
> >daemon threads in a webapp.
> >
> >It would take all of 2 minutes to write a timer with crontab and wget
> >that could call your servlet whenever you want.
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >  
> >
> 
> 


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com">www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message