Agent Skillsiii-hq/iii › iii-cron

iii-cron

GitHub

iii-cron 是一个定时任务调度组件,支持通过 cron 表达式注册函数周期性执行。具备分布式锁机制确保集群内单次执行,支持条件跳过和漂移监控,适用于无需外部调度器的后台定时作业。

engine/src/workers/cron/skills/SKILL.md iii-hq/iii

Trigger Scenarios

需要周期性执行后台任务(如数据清理、报表生成) 需要在多实例集群中保证定时任务仅执行一次 需要根据特定条件动态跳过定时任务的执行

Install

npx skills add iii-hq/iii --skill iii-cron -g -y
More Options

Non-standard path

npx skills add https://github.com/iii-hq/iii/tree/main/engine/src/workers/cron/skills -g -y

Use without installing

npx skills use iii-hq/iii@iii-cron

指定 Agent (Claude Code)

npx skills add iii-hq/iii --skill iii-cron -a claude-code -g -y

安装 repo 全部 skill

npx skills add iii-hq/iii --all -g -y

预览 repo 内 skill

npx skills add iii-hq/iii --list

SKILL.md

Frontmatter
{
    "name": "iii-cron",
    "description": "Schedule any registered function on a 6- or 7-field cron expression, with once-only execution across a fleet when backed by the redis adapter. Its whole surface is the `cron` trigger type."
}

iii-cron

The iii-cron worker schedules a registered function to run on a recurring cron expression. It exposes no callable functions — its entire surface is one trigger type, cron, bound via iii.registerTrigger({ type: 'cron', function_id, config }). On every firing the engine builds an event payload, optionally evaluates a condition function, acquires a distributed lock through the configured adapter, and invokes the target function. Each firing reports scheduled_time vs. actual_time so drift and reentrancy are observable from inside the handler.

The schedule grammar is the seven-field cron dialect — second minute hour day-of-month month day-of-week [year] — where the year is optional and defaults to *. Both six- and seven-field forms work; the leading field is always seconds, so 0 */5 * * * * fires every 5 minutes at second 0, not every 5 seconds.

Two adapters govern once-only execution: kv (default) takes a process-local lock and is single-instance only — on a multi-instance fleet every engine fires the same job (tunables lock_ttl_ms, lock_index); redis takes a distributed lock and is required for once-only firing across a fleet (tunable redis_url).

When to Use

  • A function should run periodically without standing up a separate scheduler process or a system crontab entry.
  • You need once-only firing across a fleet — nightly cleanup, hourly reports, batch maintenance — paired with the redis adapter.
  • A scheduled job should be conditionally skipped (holiday calendar, feature flag, weekend pause) via condition_function_id without threading the check through the handler.

Boundaries

  • No callable functions — never invoked through a cron::* id; everything flows through iii.registerTrigger.
  • The default kv adapter only locks process-local; never rely on it for once-only jobs in a multi-instance deployment — use redis.
  • Reading the leading field as minutes (the five-field crontab convention) schedules jobs 60x too often; always count fields and remember position 0 is seconds.
  • For data-change or stream-change reactions use iii-state / iii-stream; iii-cron fires on the clock only.

Reactive triggers

Bind a cron trigger when a handler should run on a recurring schedule. The handler runs server-side on a tokio task spawned by the engine; with the redis adapter it fires once across the fleet per scheduled run.

Reach for it when:

  • You need recurring execution (cleanup, reports, maintenance) without an external scheduler.
  • You want condition-gated firing: set condition_function_id and the engine evaluates it before each run, skipping the handler (and releasing the lock) on a falsy or erroring result.

How to bind

  1. Register a handler: iii.registerFunction('jobs::cleanup-old-data', handler).
  2. Register the trigger:
iii.registerTrigger({
  type: 'cron',
  function_id: 'jobs::cleanup-old-data',
  config: {
    expression: '0 0 2 * * * *',  // required. sec min hour dom month dow [year]; daily at 02:00:00.
    // condition_function_id is also supported.
  },
})

expression is required and must parse, or registration fails synchronously. Bind one function_id to several triggers with distinct ids to drive multiple schedules into one handler — the trigger id arrives as job_id in the event. The handler's return value is ignored.

For the firing event payload (trigger, job_id, scheduled_time, actual_time), call iii get function info on the trigger type or handler function id.

Version History

  • c6f6fde Current 2026-08-20 17:17

Same Skill Collection

crates/iii-worker/src/sandbox_daemon/skills/SKILL.md
engine/src/workers/bridge_client/skills/SKILL.md
engine/src/workers/configuration/skills/SKILL.md
engine/src/workers/engine_fn/skills/SKILL.md
engine/src/workers/observability/skills/SKILL.md
engine/src/workers/pubsub/skills/SKILL.md
engine/src/workers/queue/skills/SKILL.md
engine/src/workers/rest_api/skills/SKILL.md
engine/src/workers/shell/skills/SKILL.md
engine/src/workers/state/skills/SKILL.md
engine/src/workers/stream/skills/SKILL.md
engine/src/workers/worker/skills/SKILL.md
skills/iii-architecture-patterns/SKILL.md
skills/iii-core-primitives/SKILL.md
skills/iii-engine-config/SKILL.md
skills/iii-error-handling/SKILL.md
skills/iii-sdk-reference/SKILL.md
skills/presentation/SKILL.md
skills/iii-getting-started/SKILL.md

Metadata

Files
0
Version
c6f6fde
Hash
35248995
Indexed
2026-08-20 17:17

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 02:16
浙ICP备14020137号-1 $Гость$