touk / pscheduler

Simple, lightweight, persistent scheduler written in Scala. Currently there are implemented Akka scheduler module and Slick jdbc persistence.

Version Matrix


Build Status Codacy Badge

pscheduler is a simple, lightweight, persistent scheduler. It's abstracting from in-memory scheduler which will be used for check that some task should be run and from persistence backend. Currently there are implemented ScheduledExecutorService-based and Akka-based in-memory scheduler and Slick jdbc persistence. Both Akka scheduler and Slick persistence are in separate modules.


In your sbt:

libraryDependencies += "pl.touk.pscheduler" %% "pscheduler-slick-store" % "0.4.0"

And then start scheduler:

import pl.touk.pscheduler._
import pl.touk.pscheduler.slick._

val pScheduler =
    .withSlickJdbcPersistence(PostgresDriver, db)
        () => limitsService.reset())



After start invocation it periodically schedules verification if some task run is needed. For this, it fetches last run tasks. Then, using configuration, scheduler checks if task should be run again. After successful run, it saves last run date.

Database migration

pscheduler-slick-store module provides Flyway migration script. To use it just create class:

package db.migration

import pl.touk.pscheduler.slick.migration.CreatingTasksTableMigration
import slick.driver.{HsqldbDriver, JdbcDriver}

class V1_001__CreateTasksTable extends CreatingTasksTableMigration {
  override protected val driver: JdbcDriver = HsqldbDriver

For more info take a look at tests.


The pscheduler is released under version 2.0 of the Apache License.