December 3, 2015 by arklay
Cron scheduler – Unity asset store plugin
Cron based scheduling for Unity3D
Get it HERE
Link to unity´s forum page (for help and doubts): HERE
This asset provides a lightweight implementation in C# of a cron scheduler adapting the code released in Random Sparks Blog.
Basically cron will allow you to define a trigger to be executed minutely, hourly, daily, weekly, monthly, yearly, on weekends, on a weekday, or on any interval or range of those. It´s a very syntax for job scheduling used in Unix-like systems for decades.
For more info about the cron syntax and its power, let me refer you to its Wikipedia page.
A basic cheat sheet:
In this example the trigger will be fired every Sunday at 2:36 am.
Every cron schedule contains 5 entries, first for minutes, second for hours, third for days, fourth for months and last one for days of the week.
Each entry can be:
- An asterisk: meaning to launch every day, hour, minute…
- A concrete value:
- 5: fire at 5am, on May or on Fridays…
- A range:
- 1-10: fire each minute from 1 to 10, every day of the day from 1 to 10…
- A list of values:
- 1,3,13: fire the trigger at 1am, 3am and 1pm…
- A divider:
- */2: on even days, even hours…
- */5: at 12am, 5am, 10am, 3pm, 8pm…
- A combination of any of them:
- 2,3,5-7: on days 2, 3, 5, 6, and 7…
- 1-10/3: on minutes 1, 4, 7, 10…
- 2,3,4-10/2: at 2am, 3am, 4am ,6am, 8am and 10am
It seems complicated but it’s not and almost every configuration can be found on the internet, just googling for example “cron odd hours” (* 1-23/2 * * *).
The component includes a custom editor with direct access to most used configurations and a quick cheat sheet:
If you have any doubt, problem or feature request please feel free to ask here.