I want to have a method run every day at 3am that will summarize a production database and insert into another database. I've seen examples of the Timer services with Java but I'm not sure that is what I am looking for. I want the program to execute on its own with me having to worry about it starting up at 3am do its work and go to sleep until 3am the next day so and so on. Any Links to pre-existing questions, blogs, or guides will be much appreciated(if there are any), thanks.
Asked
Active
Viewed 896 times
4 Answers
1
You can try with java.util.Timer
and java.util.TimerTask
classes

Alberto Saito
- 271
- 1
- 6
-
Can you elaborate a little more on this/ – Sam Orozco Oct 08 '15 at 16:51
-
See this Answer for a working example: http://stackoverflow.com/questions/9375882/how-i-can-run-my-timertask-everyday-2-pm – Alberto Saito Oct 08 '15 at 17:00
-
I know it's been a while but this is actually what I ended up doing. Your answer led me to this link which helped a lot. http://www.hascode.com/2012/06/task-scheduling-in-java-ee-6-on-glassfish-using-the-timer-service/ – Sam Orozco Feb 27 '16 at 00:34
1
There are many ways you can schedule jobs to run at a specified intervals
java.util.concurrent.ScheduledExecutorService
- Cron Jobs - You can create your own job to run
- Quartz scheduler - powerful API to schedule jobs
- Autosys Job scheduler

Saravana
- 12,647
- 2
- 39
- 57
0
The Quartz Scheduler library provides triggers to execute at a given date time or regular intervals (every day, every year, etc). You declare the schedule using a very simple trigger expression, like Cron.
See these links for more information:

Barett
- 5,826
- 6
- 51
- 55

Gaali Prabhakar
- 583
- 6
- 23
0
You can also use the Java EE Timer Service and annotation to specify when the timer runs.
@Schedule(dayOfWeek="Sun", hour="0")
public void autoTimer() { ... }

cargogod
- 3
- 3