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")
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With