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!!!
Solved! Go to Solution.
It's the missing question mark at the end. Always test the cron using an online tool before using it in the code.
Views
Replies
Total Likes
Hi,
0,15,30,45 8-10 * * * ? - it's the valid expression but not 0,15,30,45 8-10 * * *
Just checked it out there Free Online Cron Expression Generator and Describer - FreeFormatter.com
It's the missing question mark at the end. Always test the cron using an online tool before using it in the code.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies