How to define every five minutes to run jobs
How to define every five minutes to run jobs
in the play.jobs.every class ,it define an example every("1h") to run开发者_如何学编程 job every hour,bu i want to run every 5 minutes,how to define this.
i try the every("5m") or every("0.1h") ,play reports internal error.
Short answer:
You can use either of the following
@Every("5mn")
@Every("5min")
Long answer:
The @Every
annotation uses the play.libs.Time
class, and specifically the parseDuration
method to determine how often the job is scheduled.
If you look at the source code, the Javadoc states...
/**
* Parse a duration
* @param duration 3h, 2mn, 7s
* @return The number of seconds
*/
This would suggest that you should specify your code as @Every("5mn")
If you look deeper into the code, it determines that the time is in minutes by using the following regular expression.
"^([0-9]+)mi?n$"
So, this states that either of the following are valid
@Every("5mn")
@Every("5min")
Try using "5min" in your annotation instead:
@Every("5min")
精彩评论