mvniekerk / tokio-cron-scheduler

Schedule tasks on Tokio using cron-like annotation
Apache License 2.0
529 stars 59 forks source link

cron syntax for run every 1 minute runs more often #45

Closed rbtcollins closed 1 year ago

rbtcollins commented 1 year ago

I note that you don't document /N syntax, but your examples do use a (nonstandard) 1/N syntax; its not clear what the expected inputs are, particularly as /N doesn't error.



    sched
        .add(Job::new_async("*/1 * * * *", |_uuid, _l| {
            Box::pin(async {
                println!("I run every 1 minute from by cron");
            })
        })?)
        .await?;

    sched
        .add(Job::new_repeated_async(
            Duration::from_secs(60),
            |_uuid, _l| {
                Box::pin(async {
                    println!("I run every 1 minute from Duration");
                })
            },
        )?)
        .await?;
    sched.start().await?;```

results in 'I run every 1 minute' printed every 3-4 seconds.

<details>
<summary>A log</summary>

I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from by cron
I run every 1 minute from Duration
I run every 1 minute from by cron
I run every 1 minute from by cron

</details>
mvniekerk commented 1 year ago

Hi @rbtcollins - note the first item is for seconds. So, it'll run per second. Check if you change the first one to 0 and the second to */1?