This example shows how to run a scheduled job in a Play app either in the web process or outside the web process (e.g. an external scheduler like Heroku's Scheduler Addon.
By default, when running the web app locally the Tick runs every second:
./sbt ~run
You should see "tick tock" every second in the STDOUT logs.
To run just a single Tick as a standalone process, run:
./sbt runMain jobs.TickJob
You should only see a single "tick tock" and then the process exits.
- Open the Resources tab in your app's dashboard:
https://dashboard.heroku.com/apps/YOUR APP NAME/resources
- Click on the Heroku Scheduler Add-on
- Add a new scheduled task with
tick
as the command / task name - Check your app's logs to see the scheduled tick:
https://dashboard.heroku.com/apps/YOUR APP NAME/logs