duckertito duckertito - 1 year ago 159
Java Question

How to schedule a task at specific time in Scala?

I want to execute my Scala function
at particular time every day. I was reading about Akka and Play framework. However it looks like Akka supports the intervals, e.g. "execute a task every 30 minutes", but it does not support executing tasks at the exact time.
I would appreciate if someone can help me to put the things in order (using my particular example), because I am a bit missed with all the information and forum threads that I read.

So, this is my Scala object and I want to schedule
every day at 23:55.

object MyTestManager {

def main(args: Array[String]) {

val cleaner = new Cleaner()


I would be interested in doing something like this, but cannot find the way of passing it to Scala 2.10.


/** Fire at 12pm (noon) every day **/
@On("0 0 12 * * ?")
public class Bootstrap extends Job {

public void doJob() {"Maintenance job ...");


Also, after packaging the Scala code, what is the right way to launch the application so that it keeps executing every day at 23:55? Will a simple
java -jar target/scala-2.10/my-assembly-1.0.jar
do this job, or will it execute the code just once?

Answer Source

What you are looking for is Akka-Quartz.

There is a trigger functionality in there. Using that functionality you can do your task.

For more info take a look here :

  1. How to fire akka scheduler daily for a particular time?
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download