views:

79

answers:

4

Hello Everyone

I have my application on Windows platform and want a java function to be executed everyday at some particular period of time. Need some guidance how to go about it. Have already looked for some previous posts but need some understanding of which method to use and how?

Thanks.

+4  A: 

You may find Quartz of use. It's a Java framework which provides the ability to invoke tasks at particular intervals, at particular times of day etc.

So you can invoke Tomcat and the Quartz framework - built into your app and suitably configured - can invoke methods at particular intervals/times of day.

Brian Agnew
+4  A: 

If you're on Windows, use scheduled task

If you're on Linux/Unix, use cron

Lie Ryan
If he's running Tomcat, are the above of *so* much use ?
Brian Agnew
A: 

I made the same process in C#.

-First Create table that includes time table that when you want to run your function - Get time from table and calculate interval like after checking adding +1 day or 24 hours to your time which you get from table.

I made it for schedule in university.I used dayname,date,time.Like this you can control also which day ,which time will run your function

Meko
A: 

Since you are using JSP and having your own server, you might set it as a scheduled task (Windows) to run at 6AM Everyday

First this is called Cron Jobs

Go to the Task Scheduler Win 7: Start -> All Programs -> Accessories -> System Tools -> Task Scheduler

From the right panel choose "Create Basic Task ..."

Give the task a name, hit next.

In the trigger tab, choose daily, then click next.

The next tab will let you set the specified date to start launching the trigger, the time, set the time and hit next.

In the Action tab, choose "Start A Program", then Next/.

In the next tab, click browse next to the program/script field, then navigate to the location of the Apache tomcat Server and choose the application.

(for the appache from WAMP Package: wamp\bin\apache\Apache2.2.11\bin\httpd.exe) tom cat will difer a bit I guess.

hit Next then Check the "Open the Properties Dialog for this task when I click Finish" then click Finish.

Now go to the action tab, select the first and only action available, click edit.

in the program/script field and modify type a space, then URL

change the URL to the URL you use to access your page.

This will let you be able to launch the script everyday at 6AM.

sikas
httpd.exe is a server that listens to incoming requests. Calling it with a url argument doesn't execute a http GET to that url. And even if it did, this would be a complete hack. Not recommended.
gregcase
@gregcase: This works for the WAMP and I mentioned this in my reply, and I also stated that Tomcat Acache will differ from this in the location and name of the file!!
sikas