A simple helper to run cronjobs (at repeated schedule) in Bevy.

Overview

crates.io MIT/Apache 2.0 crates.io Documentation

bevy_cronjob

bevy_cronjob is a simple helper to run cronjobs (at repeated schedule) in Bevy.

Usage

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")
}

Expression

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.

Supported Versions

bevy bevy_cronjob
0.11 0.1

License

Dual-licensed under either

  • MIT
  • Apache 2.0
You might also like...
Simple RUST game with the Bevy Engine

Simple RUST Game using the Bevy Engine YouTube videos for this code base: Episode 1 - Rust Game Development tutorial from Scratch with Bevy Engine Epi

Simple 2d pinball game for testing of bevy and rapier.
Simple 2d pinball game for testing of bevy and rapier.

Pinball2D Using the Bevy game engine and Rapier physics engine for a simple 2D pinball game. pinball2d.mov Wrote a short piece about how the game was

A simple authoritative server networking library for Bevy.

Bevy Networking Plugin This is a simple networking plugin for the Bevy game engine. This plugin provides the building blocks which game developers can

A simple camera for properly displaying tile-based low resolution pixel perfect 2D games in bevy.
A simple camera for properly displaying tile-based low resolution pixel perfect 2D games in bevy.

Bevy Tiled Camera A simple camera for properly displaying low resolution pixel perfect 2D games in bevy. The camera will adjust the viewport to scale

Simple island generator written in rust using bevy engine
Simple island generator written in rust using bevy engine

Getting Started Easy enough to run cargo run --release Change generation speed Find the system set that looks like this .add_system_set(

Bevy is a refreshingly simple data-driven game engine built in Rust

What is Bevy? Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever! WARNING Bevy is still in the ve

Simple stupid noise primitives for WGSL and Rust (glam/bevy types)
Simple stupid noise primitives for WGSL and Rust (glam/bevy types)

noisy_bevy Simple stupid noise primitives for glam types (Vec2, Vec3) and wgsl. Main motivations are: ergonomic usage with Bevy same results on rust a

A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!
A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!

Bevy Wrapping Square example A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that

Simple action system for Bevy.

bevy_action Simple action system for Bevy. Introduction This plugin exists mainly to facilitate a common action system for other plugins to hook in to

Owner
ZoOL
ZoOL
Helper functions and structs for working with 2D space in Bevy.

About Baffled by quaternions? Want to accelerate an object in 2D? Wish that there was a simple way to work with grids? Just want to know if two axis-a

Leafwing Studios 11 May 9, 2022
A helper bevy plugin to handle downloading OpenStreetMap-compliant slippy tiles

Bevy Slippy Tiles A helper bevy plugin to handle downloading OpenStreetMap-compliant slippy tiles. [DownloadSlippyTilesEvent] can be fired to request

Edouard Poitras 4 Jan 25, 2023
A Bevy helper to easily manage resources that need to persist across game sessions.

bevy-persistent A Bevy helper to easily manage resources that need to persist across game sessions. Background In games, there are a lot of resources

Umut 5 Mar 25, 2023
A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

null 3 May 8, 2023
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sélène Amanita 11 May 28, 2023
Windows game hack helper utilities in rust.

⚗️ toy-arms Windows game hack helper utilities in rust. This crate has some useful macros, functions and traits. ?? How to use this crate? With this c

s3pt3mb3r 100 Jan 1, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

研究社交 208 Dec 27, 2022
Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

Adam 7 Oct 4, 2023
A prototype plugin providing a simple line drawing api for bevy.

bevy_debug_lines A prototype plugin providing a simple line drawing api for bevy. See docs.rs for documentation. Expect breakage on master. Click on t

Michael Palmos 92 Dec 31, 2022