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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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, offset::Local};
use chrono::{DateTime, Duration, Utc};
use cron::OwnedScheduleIterator;

/// Description and state of a job.
struct Job {
/// Job index, used as identifier for logging.
id: usize,
/// Schedule iterator.
upcoming: OwnedScheduleIterator<Local>,
upcoming: OwnedScheduleIterator<Utc>,
/// Next time this job will run.
next: Option<DateTime<Local>>,
next: Option<DateTime<Utc>>,
/// Shell command.
command: String,
/// Whether the process is running.
Expand All @@ -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.
Expand Down Expand Up @@ -88,7 +88,7 @@ fn load_jobs(jobs: &mut Vec<JobHandle>, 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,
Expand Down
Loading