Planning a crontab style in Play 2.4.x?

Technically, I can install cron on the machine and twist the url, but I try to avoid this. Any way to achieve this?

Reason: I want to avoid cron, so I can easily change the schedule or completely stop it without also doing ssh'ing into the machine to do this.

+5
source share
3 answers

Take a look at: https://github.com/enragedginger/akka-quartz-scheduler . See http://quartz-scheduler.org/api/2.1.7/org/quartz/CronExpression.html for valid CronExpressions examples and examples.

Example from the docs:

An example of a graph called Every-30-Seconds that, exactly, fires every 30 seconds:

akka { quartz { schedules { Every30Seconds { description = "A cron job that fires off every 30 seconds" expression = "*/30 * * ? * *" calendar = "OnlyBusinessHours" } } } } 

You can integrate this into your game! applications (possibly in your global application)

+6
source

You can use the Akka scheduler.

 val scheduler = Akka.system(app).scheduler scheduler.schedule(0 seconds, 1 hour) { // run this block every hour } 

The first parameter is the delay, so if you want to delay a certain time, you can easily calculate the target time using simple date arithmetic.

+3
source

Check out https://github.com/philcali/cronish

Sample code from README.md :

 val payroll = task { println("You have just been paid... Finally!") } // Yes... that how you run it payroll executes "every last Friday in every month" val greetings = job (println("Hello there")) describedAs "General Greetings" // give a delayed start val delayed = greetings runs "every day at 7:30" in 5.seconds // give an exact time to start val exact = greetings runs "every day at noon" starting now + 1.week // resets a job to its definition val reseted = exact.reset() reseted starting now + 1.day 
+2
source

All Articles