Crates.io | bevy_cronjob |
lib.rs | bevy_cronjob |
version | |
source | src |
created_at | 2023-08-02 06:15:11.495121 |
updated_at | 2024-10-23 02:13:10.147051 |
description | A simple helper to run cronjobs (at repeated schedule) in Bevy. |
homepage | https://github.com/foxzool/bevy_cronjob |
repository | https://github.com/foxzool/bevy_cronjob |
max_upload_size | |
id | 932439 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
bevy_cronjob
is a simple helper to run cronjobs (at repeated schedule) in Bevy.
use std::time::Duration;
use bevy::{ MinimalPlugins};
use bevy::app::{App, PluginGroup, ScheduleRunnerPlugin, Update};
use bevy::log::{info, LogPlugin};
use bevy_ecs::prelude::{IntoSystemConfigs};
use bevy_cronjob::schedule_passed;
fn main() {
App::new()
.add_plugins(
MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(
1.0 / 60.0,
))),
)
.add_plugins(LogPlugin::default())
.add_systems(Update, print_per_5_sec.run_if(schedule_passed("0/5 * * * * *")))
.add_systems(Update, print_per_min.run_if(schedule_passed("0 * * * * *")))
.add_systems(Update, print_per_hour.run_if(schedule_passed("0 0 * * * *")))
.run();
}
fn print_per_5_sec() {
info!("print every 5 sec")
}
fn print_per_min() {
info!("print every minute")
}
fn print_per_hour() {
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.15 | 0.5 |
0.14 | 0.4 |
0.13 | 0.3 |
0.12 | 0.2 |
0.11 | 0.1 |
Dual-licensed under either