A simple scheduler based on Akka.
val stack = mutable.Stack[String]()
val expression = CronExpression("0 0 2-3 * * * *")
SimpleScheduler.start()
SimpleScheduler.scheduleJob(expression, Job("Add to stack", Runnable {
stack.push("Hi")
}))
CronExpression cronExpression = new CronExpression("* * * * * * *");
SimpleScheduler.scheduleJob(cronExpression, new Job("A Job!", () -> System.out.println("run....")));
SimpleScheduler.start();
- Pattern: "SM MH HD DM DW MY YY"
SM: Second of minute MH: Minute of the hour HD: Hour of the day DM: Day of the Month DW: Day of the week MY: Month of the year YY: Year
- Each Cron Item can take:
"*": Match any value of a given instance "\d+(,\d+)*": Match one value or a list of values "\d+/\d+": Match a starting value and a step "\d+-\d+(/\d+)": Match a range and optionaly a step inside the range Possible values depends on the domain of the particular cron item (eg: to Seconds will be 0-59)
- Examples:
"* * * * * * *" -> Every second "0 * * * * * *" -> Each 0 second of every minute "* 0 * * * * *" -> Every second at minute 0 of every hour "0 0 13 * 1 * *" -> Every monday at 1 PM