scorpiox-bot-plugin-crontab

scorpiox-bot-plugin-crontab

main1 branch · 0 tags
VS Code
HTTPS
ForkDelete
Recent Commits
README

plugin_crontab — SCORPIOX BOT open-source cron schedule inspector

A clean-room, MIT-licensed SCORPIOX BOT dynamic plugin that

shows the scheduled entries on your own node, explains what each cron expression

means in plain English, and computes the exact next five firing times — in UTC and in

your local time. It also ships an interactive cron playground that works on any machine,

even one with zero cron jobs installed.

One C99 file. No dependencies. No daemon of its own. No outbound network requests.

plugin_crontab --meta
{"name":"crontab","desc":"Cron jobs"}

What it does

Area Detail
Job listing Reads crontab -l, /etc/crontab and every file in /etc/cron.d on Linux and macOS. On Windows it reads schtasks /Query /FO CSV /NH.
Schedule parsing Full five-field syntax: *, N, a-b, */step, a-b/step and comma lists, plus month and weekday names (JAN, mon-fri, ...). 0 and 7 both mean Sunday.
Keywords @reboot, @hourly, @daily, @midnight, @weekly, @monthly, @yearly, @annually.
Plain English Every expression is described: Every 15 minutes, between 09:00 and 17:59, on Monday, Tuesday, Wednesday, Thursday, Friday.
Next runs The next five firing times, as ISO-8601 UTC and as local YYYY-MM-DD HH:MM, with a second-by-second countdown in the UI.
Playground Type any expression and get live validation plus its next five runs. Works with no crontab present.
Day semantics Honours the classic cron rule: when both day-of-month and day-of-week are restricted, a day matches if either field matches.
Theme Follows the Bot theme (localStorage.bot_theme), dark by default, no flash.
Embed mode ?embed=1 drops the back-link so it fits the chat floating window.

Why it is safe

1. Strictly read-only. There is no code path that writes a crontab, installs a

scheduled task, or executes a scheduled command. The only external programs invoked are

crontab -l (POSIX, list) and schtasks /Query (Windows, query). Both are read-only and

both are hard-coded — no user-supplied value ever reaches a command line, so there is no

injection surface at all.

2. Node authentication. The node API (:8150) is reachable from the LAN, so the plugin

refuses any request that does not carry the node password. Accepted forms match the rest of

the node API: X-Bot-Password: <pwd> (what bot-web proxies with), `Authorization: Bearer

<pwd>, or ?pwd=<pwd> (what the plugin iframe appends). If BOT_PASSWORD` is unset the node

is in explicitly open mode and the check is a no-op, exactly like terminal_tmux.c.

3. Deterministic fixture mode. CRONTAB_FILE=/path/to/file makes the parser read that

file instead of the live machine. That is what the test suite uses, and it means the whole

scheduler model can be audited offline without touching a real crontab.

4. No network egress. The binary contains no http://, no https:// and no socket

call. All it does is read local files and print.


Install

Pre-built (no compiler needed)

# Linux x86_64 — the static musl binary works on Alpine, Debian, Ubuntu, Arch, Omarchy
mkdir -p ~/.scorpiox/plugins
curl -fsSL https://dist.scorpiox.net/bot-plugins/crontab/1.0.0/linux-x86_64-musl/plugin_crontab \
  -o ~/.scorpiox/plugins/plugin_crontab
chmod +x ~/.scorpiox/plugins/plugin_crontab
~/.scorpiox/plugins/plugin_crontab --meta

On Windows, put plugin_crontab.exe in %LOCALAPPDATA%\scorpiox\plugins\.

On a BotCloud container, use /workspace/.scorpiox/plugins/ so it survives restarts.

No server restart is required — scorpiox-server resolves plugin routes live.

From source

git clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-crontab.git
cd scorpiox-bot-plugin-crontab
make            # native build -> ./plugin_crontab
make musl       # fully static Linux -> ./plugin_crontab.musl
make win64      # static Windows PE -> ./plugin_crontab.exe
make test       # 80+ offline assertions

Agent-assisted build

Paste this into SCORPIOX BOT Chat:

Clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-crontab.git, audit
src/plugin_crontab.c for safety, customise it for my setup, compile it natively on this
machine, verify --meta, and install it to ~/.scorpiox/plugins/.

Because the plugin is a single dependency-free C99 file, that takes seconds.


HTTP API

All JSON responses are Content-Type: application/json; charset=utf-8 with

Cache-Control: no-store.

?action=jobs (alias list, or ?format=json)

{
  "ok": true,
  "action": "jobs",
  "plugin": "plugin_crontab",
  "version": "1.0.0",
  "now_utc": "2026-11-11T04:49:22Z",
  "now_local": "2026-11-11 04:49",
  "count": 7,
  "truncated": false,
  "sources": ["user", "/etc/crontab"],
  "jobs": [
    {
      "source": "user",
      "kind": "cron",
      "expr": "*/5 * * * *",
      "command": "/usr/bin/backup.sh --flag",
      "user": "",
      "valid": true,
      "description": "Every 5 minutes, every day",
      "next": [
        {"utc": "2026-11-11T04:50:00Z", "local": "2026-11-11 04:50", "in_seconds": 38}
      ]
    }
  ]
}

count is the number of scheduled entries found. truncated is set when the node has more

than 512 entries. Lines that fail to parse are still listed with valid: false and an

error string, rather than being silently dropped.

?action=explain&expr=<expression>

{
  "ok": true,
  "action": "explain",
  "expr": "*/15 9-17 * * 1-5",
  "valid": true,
  "keyword": "",
  "description": "Every 15 minutes, between 09:00 and 17:59, on Monday, Tuesday, Wednesday, Thursday, Friday",
  "normalized": "*/15 9-17 * * 1-5",
  "fields": {"minute": "*/15", "hour": "9-17", "day_of_month": "*", "month": "*", "day_of_week": "1-5"},
  "boot_only": false,
  "now_utc": "2026-11-11T04:47:32Z",
  "now_local": "2026-11-11 04:47",
  "next": [
    {"utc": "2026-11-11T09:00:00Z", "local": "2026-11-11 09:00", "in_seconds": 15148}
  ]
}

Invalid expressions return "valid": false with a specific error

(minute out of range 0-59, expected 5 fields, unknown @keyword, ...).

@reboot returns "boot_only": true and an empty next array — it has no clock times.

Explanations are always available, on any machine, whether or not a crontab exists.

?action=info

Plugin identity, version, supported actions, capabilities and the trust notice.


Scope boundaries

  • Read-only. No crontab writes, no task creation, no command execution.
  • No network. No sockets, no HTTP client, no telemetry.
  • Two external programs, both query-only: crontab -l and schtasks /Query.
  • No user input reaches a shell. Fixture paths come from the environment, not the query.
  • Next-run horizon is twenty years, which covers every expression including

0 0 29 2 * (29 February) and 0 0 1 1 * (1 January).


Layout

src/plugin_crontab.c   the whole plugin: cron parser, next-run engine, JSON API, HTML UI
tests/run.sh           155 offline assertions, all against fixtures
tests/e2e.py           Playwright viewport suite at 1440 / 1024 / 390
Makefile               all / musl / win64 / macos / test / clean
build.ps1              Windows PowerShell build with an MZ sanity check
release-dist.sh        secret scan -> multi-target build -> dist upload -> plugingit mirror

Licence

MIT. See LICENSE.