Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ repository = "https://github.com/stephank/pocketcron"

[dependencies]
chrono = { version = "0.4.26", default-features = false, features = ["clock"] }
cron = "0.16.0"
# Unreleased fix for the DST fall-back hang (zslayton/cron#145). Switch back to a crates.io release once one includes it.
cron = { git = "https://github.com/zslayton/cron", rev = "cf2dc1d519246de9ad230d33de2b7cd65e30305e" }
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ 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.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ use std::{
thread,
};

use chrono::{DateTime, Duration, Utc};
use chrono::{DateTime, Duration, offset::Local};
use cron::OwnedScheduleIterator;

/// Description and state of a job.
struct Job {
/// Job index, used as identifier for logging.
id: usize,
/// Schedule iterator.
upcoming: OwnedScheduleIterator<Utc>,
upcoming: OwnedScheduleIterator<Local>,
/// Next time this job will run.
next: Option<DateTime<Utc>>,
next: Option<DateTime<Local>>,
/// Shell command.
command: String,
/// Whether the process is running.
Expand All @@ -40,7 +40,7 @@ fn main() {
}

loop {
let now = Utc::now();
let now = Local::now();

// Find the minimum of all jobs' `next` time.
// Max sleep is 1 minute, to account for any clock jumps.
Expand Down Expand Up @@ -88,7 +88,7 @@ fn load_jobs(jobs: &mut Vec<JobHandle>, path: OsString) {
};

// Read by line.
let now = Utc::now();
let now = Local::now();
for (line_no, line) in BufReader::new(file).lines().enumerate() {
let line = match line {
Ok(line) => line,
Expand Down
Loading