3

I don't have experience with cron4j scheduler and I need to schedule tasks with different time. Use cron4j is requirement, so I have to use it. I've tried to find tutorial but unsuccessfully. Can someone help me. I don't want full code here now, just recommendation how to do that or link with tutorial. I've read cron4j documentation, but I've not found what I need. I appreciate every help. Thanks.

Martin
  • 2,146
  • 4
  • 21
  • 32
  • I believe the documentation has more than enough to cover cron4j usage. What exactly do you need to do that you can't find in the documentations ? – Muhammad Gelbana Jan 28 '13 at 22:43

2 Answers2

2

Sorry I'm late to the party.

This is exactly the question I struggled with on this thread

However I managed to find 'a' way to implement multiple schedules.

If you have different tasks you want to execute at different times. Create different schedulers:

// Creates a Constituent Scheduler instance.
Scheduler myFirstScheduler = new Scheduler();

// Creates a Summary Scheduler instance.

Scheduler mySecondScheduler = new Scheduler();

// Schedule a once-a-week task at 8am on Sunday.        
myFirstScheduler("0 8 * * 7", new Runnable() {
    public void run() {
        //DO SOMETHING

    }
});


//Schedule a twice a day task at 7am and 6pm on weekdays
mySecondScheduler("0 7 * * 1-5 |0 18 * * 1-5 ", new Runnable() {
    public void run() {
        //DO SOMETHING
    }
});
Community
  • 1
  • 1
TheMightyLlama
  • 1,243
  • 1
  • 19
  • 51
0

Here's cron4j documentation. There are code samples also. In general scheduling is done through call to Scheduler#schedule method which accept String in linux cron format e.g. * * * * *

Archer
  • 5,073
  • 8
  • 50
  • 96