bevy_cronjob
is a simple helper to run cronjobs (at repeated schedule) in Bevy.
``` rust use std::time::Duration; use bevy::{ MinimalPlugins}; use bevy::app::{App, PluginGroup, ScheduleRunnerPlugin, Update}; use bevy::log::{info, LogPlugin};
use bevyecs::prelude::{IntoSystemConfigs}; use bevycronjob::schedule_passed;
fn main() { App::new() .addplugins( MinimalPlugins.set(ScheduleRunnerPlugin::runloop(Duration::fromsecsf64( 1.0 / 60.0, ))), ) .addplugins(LogPlugin::default()) .addsystems(Update, printper5sec.runif(schedulepassed("0/5 * * * * *"))) .addsystems(Update, printpermin.runif(schedulepassed("0 * * * * *"))) .addsystems(Update, printperhour.runif(schedule_passed("0 0 * * * *"))) .run() }
fn printper5_sec() { info!("print every 5 sec") }
fn printpermin() { info!("print every minute") } fn printperhour() { info!("print every hour") } ```
the scheduling expression is base on cron
| sec | min | hour | day of month | month | day of week | year | |------|------|------|--------------|-------|-------------|-----------| | * | * | * | * | * | * | * | | 0-59 | 0-59 | 0-23 | 1-23 | 1-12 | 1-7 | 1970-2100 |
Time is specified in UTC. Note that the year may be omitted.
Comma separated values such as 1,2,3
are allowed. For example, a schedule of 0,15,30,45 * * * * *
' would execute on every 15 seconds.
Ranges can be specified with a dash. For example 1-5 * * * * *
' would execute on every second for the first 5 seconds of a minute.
| bevy | bevy_cronjob | |------|--------------| | 0.11 | 0.1 |
Dual-licensed under either