Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 465
Lion Avatar asked Jun 03 '11 07:06

Lion


2 Answers

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")
like image 174
Codemwnci Avatar answered Oct 08 '22 14:10

Codemwnci


Try using "5min" in your annotation instead:

@Every("5min")
like image 30
dogbane Avatar answered Oct 08 '22 15:10

dogbane