localjobs: a local cron scheduler that tells you when jobs fail
$5
Plain cron runs your scripts and forgets about them. When a backup hangs, a token expires, or a script prints an error and exits 0, you find out weeks later. localjobs is a small scheduler for the...
Read full descriptionDescription
Plain cron runs your scripts and forgets about them. When a backup hangs, a token expires, or a script prints an error and exits 0, you find out weeks later. localjobs is a small scheduler for the automations you run on your own Mac or Linux box. It runs them on schedule and keeps track of how each one went.
You list jobs in one JSON file (name, cron schedule, command, args, timeout). localjobs runs them, keeps a log file per job, and records the last run, status, exit code, and last lines of output for each. A local status API and an optional Discord alert tell you when something breaks, and again when it recovers.
Features
- Cron schedules: standard 5-field expressions,
@daily-style shortcuts,@every 10m, and several schedules per job - Timeouts that actually kill: each job runs in its own process group, so a timeout stops the command and everything it started
- Per-job log files with a start and end line for every run (status and duration)
- Catches "successful" failures:
fail_on_output_regexfails a run when output likeTracebackorERROR:appears, even with exit code 0 - Late and missed runs: runs that fire late after sleep are logged,
skip_if_late_minutesskips stale catch-up runs, and jobs that missed their last scheduled time are flaggedoverdue - No pile-ups: a run that's still going blocks the next one, which is skipped and counted
- Status API on localhost:
/api/health(with an optional 503 mode for uptime monitors) and/api/jobswith last run, status, error, and counts. Read-only, so nothing can trigger jobs over HTTP. - Optional Discord alerts on the first failure and on recovery, set with one environment variable
- Last results survive restarts through an optional state file
- Graceful shutdown: running jobs get a grace period before they are killed
-checkvalidates the config and shows upcoming runs, and-run <job>runs a job by hand- launchd and systemd templates included
- Prebuilt static binaries for macOS (Apple silicon and Intel) and Linux (x86-64 and ARM64), plus the full Go source (one dependency) and a test suite
Example /api/jobs entry
{
"name": "backup-notes",
"schedules": ["30 2 * * *"],
"last_status": "timeout",
"last_error": "timed out after 30m0s, process group killed",
"consecutive_failures": 1,
"next_run": "2026-03-11T02:30:00-05:00",
"overdue": false
}Requirements
- macOS 12+ or Linux (x86-64 or ARM64). Windows builds from source but is untested.
- No runtime dependencies. Go 1.21+ only if you build from source.
- Optional: a Discord webhook URL for alerts
Limitations
- The config is read at startup, so restart the service after editing it (no hot reload)
- Missed runs while the computer is off are flagged as overdue, not replayed later
- Single machine. No web UI, job dependencies, retries, or log rotation.
- macOS binaries aren't code-signed (the README shows the one-line fix if macOS blocks them)
Good to know
localjobs runs the commands you configure with your user's permissions, so review your job commands. If alerts are on, the last lines of a failing job's output are sent to your Discord webhook.
Files included
local-job-schedulerlocal-job-scheduler
binbin
- localjobs-darwin-amd64localjobs-darwin-amd646.9 MB
- localjobs-linux-amd64localjobs-linux-amd646.8 MB
- localjobs-darwin-arm64localjobs-darwin-arm646.4 MB
- localjobs-linux-arm64localjobs-linux-arm646.3 MB
- SHA256SUMSSHA256SUMS354 B
- localjobs_test.golocaljobs_test.go15 KB
- scheduler.goscheduler.go12.9 KB
- README.mdREADME.md10.9 KB
- config.goconfig.go5.4 KB
- main.gomain.go4.7 KB
- api.goapi.go4.6 KB
serviceservice
- localjobs.plistlocaljobs.plist1.5 KB
- localjobs.servicelocaljobs.service1 KB
- config.example.jsonconfig.example.json1.4 KB
- CHANGELOG.mdCHANGELOG.md1.1 KB
- notify.gonotify.go1.1 KB
- proc_unix.goproc_unix.go440 B
- go.sumgo.sum169 B
- proc_other.goproc_other.go162 B
- go.modgo.mod68 B
- .gitignore.gitignore40 B
README
local-job-scheduler/README.md
localjobs: cron that tells you when things fail
localjobs is a single-binary job scheduler for personal automations: backups, sync scripts, report generators, cleanup tasks. You list your jobs in one JSON file. It runs them on cron schedules, keeps a log per job, kills anything that runs too long, and tells you when a job fails, instead of failing silently the way plain cron does.
- Cron schedules (
*/30 * * * *,@daily,@every 10m), with several schedules per job if needed. - Timeouts that actually kill. Each job runs in its own process group, so a timeout kills the command and everything it started (shell pipelines, child scripts).
- A log file per job, with a start and end line for every run (status and duration).
- Failure tracking: last run, last status, exit code, the last few lines of output, run/success/failure counts, and consecutive failures. Kept across restarts in a state file.
- Catches "successful" failures. Many scripts print an error and still exit 0.
fail_on_output_regexmarks a run as failed when any output line matches, for exampleTraceback|ERROR. - Late and missed runs. A run that fires late (the laptop was asleep) is logged and its
lateness recorded.
skip_if_late_minutesskips stale catch-up runs. Jobs that missed their last scheduled run are flaggedoverdue. - No pile-ups. If a run is still going when the next one is due, the new one is skipped and counted.
- Status API on localhost:
/api/healthand/api/jobs. - Optional Discord alert on failure and on recovery. Set one environment variable, or leave it unset.
- Graceful shutdown: on stop, running jobs get time to finish before they are killed.
- About 1,100 lines of Go with one dependency (robfig/cron), and a test suite.
What it looks like
config.json (excerpt):
{
"listen": "127.0.0.1:8787",
"state_file": "~/.local/state/localjobs/state.json",
"jobs": [
{
"name": "disk-space-check",
"enabled": true,
"schedule": "*/30 * * * *",
"command": "/bin/sh",
"args": ["-c", "df -h / | tail -n 1"],
"timeout": 30,
"fail_on_output_regex": "\\s(9[5-9]|100)%\\s"
},
{
"name": "backup-notes",
"enabled": true,
"schedule": "30 2 * * *",
"command": "/usr/bin/rsync",
"args": ["-a", "~/Documents/notes/", "~/Backups/notes/"],
"timeout": 1800
}
]
}curl -s localhost:8787/api/jobs (one entry):
{
"name": "backup-notes",
"enabled": true,
"schedules": ["30 2 * * *"],
"running": false,
"overdue": false,
"next_run": "2026-03-11T02:30:00-05:00",
"last_run": "2026-03-10T02:30:00.004-05:00",
"last_status": "timeout",
"last_error": "timed out after 30m0s, process group killed\nlast output:\nrsync: connection unexpectedly closed",
"last_exit_code": null,
"last_duration_ms": 1800012,
"last_success": "2026-03-09T02:31:12.551-05:00",
"run_count": 41,
"success_count": 40,
"failure_count": 1,
"consecutive_failures": 1,
"skip_count": 0,
"log_file": "/home/you/.local/state/localjobs/logs/backup-notes.log"
}And in Discord:
[localjobs] TIMEOUT: backup-notes on my-laptop (failure 1 in a row)
timed out after 30m0s, process group killedInstall
Prebuilt binaries are in bin/ for macOS (Apple silicon and Intel) and Linux (x86-64 and
ARM64). They are static and have no dependencies. Check them against bin/SHA256SUMS if you like.
# pick the one for your machine
cp bin/localjobs-darwin-arm64 ~/.local/bin/localjobs # or /usr/local/bin
chmod +x ~/.local/bin/localjobs
localjobs -versionOn macOS the binaries are not code-signed. If macOS blocks it ("cannot be opened because the
developer cannot be verified"), clear the download flag once:
xattr -d com.apple.quarantine ~/.local/bin/localjobs. Or build it yourself:
Build from source (Go 1.21 or newer; on recent macOS versions use a current Go release, since binaries from older Go toolchains can fail to launch there):
go build -o localjobs .
go test ./...Usage
cp config.example.json config.json # then edit it
localjobs -config config.json -check # validate and show the next run times
localjobs -config config.json -run disk-space-check # run one job now, exit 0/1 with its result
localjobs -config config.json # run the scheduler in the foreground (Ctrl-C to stop)-check exits with code 2 and a clear message on any config mistake: bad cron expression,
duplicate job name, empty command, invalid regex, or an unknown key (typos are rejected
instead of silently ignored).
Configuration
Top-level keys (all optional):
| Key | Default | What it does |
|---|---|---|
listen | "" (off) | Address for the status API. Keep it on 127.0.0.1. |
log_dir | ~/.local/state/localjobs/logs | Where per-job logs go when a job has no log_file. |
log_file | "" (stderr) | The scheduler's own log. Leave empty under launchd/systemd. |
state_file | "" (memory only) | JSON file of last results, so status survives restarts. Recommended. |
max_concurrent_jobs | 4 | Jobs allowed to run at once. Others wait their turn. |
default_timeout_seconds | 3600 | Timeout for jobs that don't set one. |
late_threshold_seconds | 120 | A run this far behind schedule counts as late or overdue. |
shutdown_grace_seconds | 30 | On stop, how long running jobs get before they are killed. |
alert_repeat | false | false alerts on the first failure in a streak; true on every failure. |
alert_on_recovery | true | Alert when a failing job succeeds again. |
Per-job keys:
| Key | Required | What it does |
|---|---|---|
name | yes | Unique. Letters, digits, ., _, -. |
enabled | false keeps the job in the file but never schedules it. Default false, so set it to true. | |
schedule / schedules | yes | Standard 5-field cron (min hour day month weekday), @hourly, @daily, @weekly, or @every 10m. Use schedules for a list. Times are in the machine's local time zone. |
command | yes | Program to run. Use an absolute path; services start with a minimal PATH. For shell syntax use "/bin/sh" with "args": ["-c", "..."]. |
args | Arguments. A leading ~/ is expanded. No other shell expansion happens. | |
dir | Working directory. | |
env | Extra environment variables, e.g. {"API_MODE": "prod"}. | |
timeout | Seconds before the job is killed. | |
log_file | Defaults to <log_dir>/<name>.log. Output is appended. Rotate it yourself if it grows (e.g. newsyslog/logrotate). | |
status_file | Written with a timestamp after each successful run, for other tools to check. | |
fail_on_output_regex | Go regular expression, matched against each output line (stdout and stderr). A match fails the run even on exit code 0. | |
skip_if_late_minutes | Skip a run that fires more than this many minutes after its scheduled time. 0 (default) always runs. | |
alert | false mutes alerts for this job. | |
description | Shown in the API. |
Status API
Both endpoints are read-only GETs that return JSON.
GET /api/health:statusisok, ordegradedwhen any enabled job's last run failed or a job is overdue. It also listsfailingandoverduejob names, counts, uptime, and version. Add?strict=1to get HTTP 503 when degraded, which works for uptime monitors.GET /api/jobs: every job, in config order (fields as in the example above).GET /api/jobs/<name>: one job.
last_status is one of never_run, success, failed, timeout. overdue: true means the
job's most recent scheduled run didn't happen: the scheduler was down, the computer was off, or
the run was skipped as late.
There is no endpoint that starts jobs, so a web page in your browser can't trigger anything
on your machine. Use localjobs -run <name> to run a job by hand.
Discord alerts (optional)
In Discord, open Server Settings → Integrations → Webhooks → New Webhook, pick a channel,
and copy the URL. Put it in the LOCALJOBS_DISCORD_WEBHOOK environment variable (the service
templates have a slot for it). Then test it:
LOCALJOBS_DISCORD_WEBHOOK='...' localjobs -test-alertAn alert includes the job name, status, host name, and the last few lines of output. Note that
this output goes to Discord, so mute ("alert": false) jobs whose output may contain secrets.
If the variable is unset, alerts are off.
Run it as a service
macOS (launchd): edit service/localjobs.plist (replace each /path/to/... with an
absolute path), then:
cp service/localjobs.plist ~/Library/LaunchAgents/com.example.localjobs.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.localjobs.plist
launchctl kickstart -k gui/$(id -u)/com.example.localjobs # restart, e.g. after config editsLinux (systemd user service): the template expects the binary at ~/.local/bin/localjobs
and the config at ~/.config/localjobs/config.json.
mkdir -p ~/.config/systemd/user && cp service/localjobs.service ~/.config/systemd/user/
systemctl --user daemon-reload && systemctl --user enable --now localjobs
systemctl --user restart localjobs # after config edits
journalctl --user -u localjobs -f # scheduler log
loginctl enable-linger "$USER" # optional: keep running when logged outBoth templates send the stop signal to localjobs only, so running jobs get
shutdown_grace_seconds to finish before they are killed.
Limitations
- Restart after config edits. The config is read once at startup. There is no hot reload.
-checkfirst, then restart the service. - Exit codes are trusted by default. A script that hides its own errors and exits 0 counts
as success unless you set
fail_on_output_regexor make the script exit non-zero (set -ein shell). The regex sees output line by line, so it can't match across lines. - Missed runs are flagged, not replayed. If the computer is off at 02:30, that run doesn't
happen later. It shows as
overdueuntil the next scheduled run. Runs missed during sleep do fire on wake (and are logged as late) unless you setskip_if_late_minutes. @everyintervals restart from scheduler start.@every 1hmeans one hour after localjobs started, then hourly. Use a cron expression for fixed clock times.- One machine, one process. No clustering, no web UI, no job dependencies or retries. Retry inside the script if you need it.
- Logs are not rotated by localjobs.
- Windows builds from source but isn't tested, and a timeout there kills only the direct child process, not its children.
- Around daylight-saving changes, a job scheduled inside the skipped or repeated hour (usually 1 to 3 AM) may be skipped or run at a shifted time. Avoid that window if it matters.
Tests
go test ./...The tests run real short shell commands (/bin/sh, sleep) in temp directories and use local
test servers for the API and Discord. They need no network and take about 3 seconds on macOS or Linux.
Reviews
No reviews