Regarding scheduling tasks without Quartz
, you can use Java's ScheduledExecutorService:
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
final Runnable beeper = new Runnable() {
public void run() { System.out.println("beep"); }
};
// Beeps every 10 seconds
scheduler.scheduleAtFixedRate(beeper, 0, 10, TimeUnit.SECONDS);
Now, regarding doing it when your application is not running, I see three options:
- Develop a stand-alone application with your scheduled tasks, decoupled from your webapp
- Look up for Application Server features for that purpose
- OS scheduled tasks, as Linux's cron job