diff --git a/Dockerfile b/Dockerfile index f0a3fb5..0e7fbd5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM rust AS build WORKDIR /usr/src/pocketcron COPY . . -RUN cargo install --path . +RUN cargo install --locked --path . FROM debian COPY --from=build \ diff --git a/README.md b/README.md index b1c3f68..3e5610c 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,6 @@ A tiny cronjob runner. Great as a 'sidecar' process in your application. - Supports only the user crontab format. (No username field, like in system crontab files.) +- Schedules are always in UTC, regardless of the system time zone. + - Not a deamon. Always runs in the foreground. diff --git a/src/main.rs b/src/main.rs index 6f7273b..12f1a62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use std::{ thread, }; -use chrono::{DateTime, Duration, offset::Local}; +use chrono::{DateTime, Duration, Utc}; use cron::OwnedScheduleIterator; /// Description and state of a job. @@ -15,9 +15,9 @@ struct Job { /// Job index, used as identifier for logging. id: usize, /// Schedule iterator. - upcoming: OwnedScheduleIterator, + upcoming: OwnedScheduleIterator, /// Next time this job will run. - next: Option>, + next: Option>, /// Shell command. command: String, /// Whether the process is running. @@ -40,7 +40,7 @@ fn main() { } loop { - let now = Local::now(); + let now = Utc::now(); // Find the minimum of all jobs' `next` time. // Max sleep is 1 minute, to account for any clock jumps. @@ -88,7 +88,7 @@ fn load_jobs(jobs: &mut Vec, path: OsString) { }; // Read by line. - let now = Local::now(); + let now = Utc::now(); for (line_no, line) in BufReader::new(file).lines().enumerate() { let line = match line { Ok(line) => line,