openclaw - 💡(How to fix) Fix [Feature]: Split jobs.json into per-job config files [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70531Fetched 2026-04-24 05:56:50
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Allow cron jobs to be stored as individual JSON files (e.g., ~/.openclaw/cron/jobs/<job-id>.json) instead of a single monolithic jobs.json file.

Error Message

Consequence: Manual editing is error-prone (one misplaced comma breaks all jobs); git diffs are noisy; agent-driven edits (via python/jq) must read-write the entire file, risking data loss on concurrent access

Root Cause

Allow cron jobs to be stored as individual JSON files (e.g., ~/.openclaw/cron/jobs/<job-id>.json) instead of a single monolithic jobs.json file.

RAW_BUFFERClick to expand / collapse

Summary

Allow cron jobs to be stored as individual JSON files (e.g., ~/.openclaw/cron/jobs/<job-id>.json) instead of a single monolithic jobs.json file.

Problem to solve

Currently all cron jobs are stored in a single ~/.openclaw/cron/jobs.json file (~22KB with 10+ jobs). This creates several issues:

  1. Readability: Hard to review or manually edit a specific job buried in a large JSON array
  2. Concurrent write risk: Multiple operations (cron edit, cron run state updates) all read/write the same file, increasing the chance of corruption
  3. Version control unfriendly: Any change to one job shows a diff on the entire file, making git history noisy
  4. Scaling concern: As users add more jobs with long message payloads, the file grows unbounded

Proposed solution: Store each job as a separate file under ~/.openclaw/cron/jobs/ (e.g., jobs/<job-id>.json or jobs/<job-name>.json), and have the gateway discover all job files in the directory on startup. Keep backward compatibility by auto-migrating the existing jobs.json on first run.

This pattern is common in systemd (one unit file per service), nginx (sites-available), and crontab.d.

Proposed solution

Store each cron job as an individual JSON file under ~/.openclaw/cron/jobs/ directory:

~/.openclaw/cron/jobs/ ├── 6d185325-news-ai-daily.json ├── f3493837-a-stock-mid.json ├── 3bcc85c8-short-trade.json └── ...

File naming: <job-id>-<job-name>.json for easy identification.

On startup, the gateway scans the directory and loads all .json files. CLI commands (cron add/edit/delete) operate on individual files instead of the monolithic jobs.json.

For backward compatibility:

  • On first run after upgrade, auto-migrate existing jobs.json → individual files
  • If jobs.json exists and jobs/ directory is empty, fall back to jobs.json

Alternatives considered

  1. Keep single jobs.json but add file locking — reduces corruption risk but doesn't solve readability, git-friendliness, or scaling issues.

  2. Use a SQLite database — more robust but harder for users to manually inspect/edit, and overkill for typically <20 jobs.

  3. YAML instead of JSON — slightly more readable but doesn't solve the single-file problem; also adds a parser dependency.

Individual files is the simplest approach that solves all the pain points while staying consistent with how other tools handle similar configs (systemd units, nginx sites-available, cron.d).

Impact

Affected: All users with 5+ cron jobs, especially power users who manage 10-15 scheduled tasks Severity: Medium — annoying, increases risk of config corruption Frequency: Daily — every cron edit/add/run touches the single file Consequence: Manual editing is error-prone (one misplaced comma breaks all jobs); git diffs are noisy; agent-driven edits (via python/jq) must read-write the entire file, risking data loss on concurrent access

Evidence/examples

Current state: a single jobs.json at ~/.openclaw/cron/jobs.json holding 13 jobs, 22KB+

$ ls -la ~/.openclaw/cron/jobs.json -rw------- 1 root root 23856 Apr 23 09:01 jobs.json

Prior art:

  • systemd: one .service file per unit in /etc/systemd/system/
  • nginx: one .conf per site in /etc/nginx/sites-available/
  • cron.d: one file per job in /etc/cron.d/
  • GitHub Actions: one .yml per workflow in .github/workflows/

All follow the same pattern: one config file per job/unit for isolation and maintainability.

Additional information

No response

extent analysis

TL;DR

Store each cron job as an individual JSON file under ~/.openclaw/cron/jobs/ to improve readability, reduce concurrent write risks, and enhance version control friendliness.

Guidance

  • Implement a directory scan on gateway startup to load all .json files from ~/.openclaw/cron/jobs/, allowing for individual job file management.
  • Update CLI commands to operate on individual files instead of the monolithic jobs.json, ensuring backward compatibility through auto-migration on first run.
  • Consider file naming conventions, such as <job-id>-<job-name>.json, for easy identification and management.
  • Evaluate the need for file locking or other concurrency controls to prevent data corruption during simultaneous edits.

Example

// Example job file: ~/.openclaw/cron/jobs/6d185325-news-ai-daily.json
{
  "jobId": "6d185325",
  "jobName": "news-ai-daily",
  "schedule": "0 0 * * *",
  "payload": "..."
}

Notes

This approach is inspired by existing configurations in systemd, nginx, and cron.d, which use individual files for each unit or job, promoting maintainability and scalability.

Recommendation

Apply the proposed solution to store each cron job as an individual JSON file, as it addresses the identified pain points while maintaining consistency with industry standards and best practices.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: Split jobs.json into per-job config files [1 participants]