#cron-job #cron #manager #jobs

cron_manager

A simple manager to add/remove cronjobs

2 releases

0.1.1 Oct 17, 2024
0.1.0 Jul 23, 2024

#25 in #cron-job

Download history 123/week @ 2024-07-22 8/week @ 2024-07-29 139/week @ 2024-10-14 7/week @ 2024-10-21 11/week @ 2024-11-04

157 downloads per month

Apache-2.0

10KB
116 lines

Cron Manager

A simple manager to add/remove cronjobs

use cron_manager::cron_manager::{CronJob, CronManager};
use rand::Rng;

fn main() {
    let mut manager = CronManager::new();
    for (i, job) in manager.list_jobs().iter().enumerate() {
        println!("{}: {}", i, job);
    }

    manager.add_job(CronJob {
        schedule: "* * * * *".to_string(),
        command: "/bin/echo hello > /tmp/hello".to_string(),
        comment: Some("testing".to_string()),
    });

    manager.add_job(CronJob {
        schedule: "* * * * *".to_string(),
        command: "/bin/echo hello > /tmp/hello".to_string(),
        comment: Some("testing".to_string()),
    });
    
    manager.remove_job(0);
    manager.remove_job_by_comment("testing");

Dependencies

~3–11MB
~145K SLoC