AEM6.4 - org.apache.sling.commons.scheduler Cron error

elizabethp60981

01-10-2019

Hi,

I am using the library org.apache.sling.commons.scheduler to create a scheduler on AEM

I am using the example below, that I found in sling documentation (Apache Sling :: Scheduler Service (commons scheduler) ) and it is working as it is, but I need to change the scheduled time to trigger every 15 minutes between 8:00a.m and 10:00am

My method:

String schedulingExpression = "0 * * * * ?";

String jobName1 = "case1";

Map<String, Serializable> config1 = new HashMap<String, Serializable>();

boolean canRunConcurrently = true;

final Runnable job1 = new Runnable() {

     public void run() {

              log.info("Executing job1");

     }

};

try {

    this.scheduler.addJob(jobName1, job1, config1, schedulingExpression, canRunConcurrently);

} catch (Exception e) {

           job1.run();

}

The problem is that everytime that I change the cron expression for anything else I have the error:

java.lang.IllegalArgumentException: Expressionis invalid : 0,15,30,45 8-10 * * *

The 0,15,30,45 8-10 * * *  is the expression that I am trying to use, online cron validators says that this is a valid expression.

Does someone have a clue of what is going on?

Thanks in advance!!!

Accepted Solutions (1)

Accepted Solutions (1)