← 返回
AI智能 中文

Cron Worker Guardrails

Use when: hardening OpenClaw cron/background workers (POSIX shells: bash/sh) against brittle quoting, cwd/env drift, and false pipeline failures (SIGPIPE, pi...
用于加固OpenClaw定时任务/后台worker(POSIX shell: bash/sh),防止脆弱的引号处理、工作目录/环境变量漂移及虚假管道失败(SIGPIPE等)
phenomenoner
AI智能 clawhub v1.0.5 1 版本 99859.9 Key: 无需
★ 0
Stars
📥 1,426
下载
💾 52
安装
1
版本
#latest

概述

Cron Worker Guardrails (POSIX)

A reliability-first checklist for OpenClaw cron workers and any unattended automation.

Scope (important)

  • This skill is POSIX-focused (bash/sh examples).
  • The principles are portable, but if you're on Windows/PowerShell you'll need equivalent patterns.

The NO_REPLY convention

Many OpenClaw setups treat emitting exactly NO_REPLY as "silent success" (no human notification).

  • If your runtime does not support NO_REPLY, interpret it as: print nothing on success.

Quick Start

1) Scripts-first: move logic into a repo script (recommended: tools/.py or tools/.sh).

2) One command in cron: cron should run one short command (no multi-line bash -lc '...').

3) Deterministic cwd/env: cd to the repo (or have the script do it), and document required env vars.

4) Silent on success: print nothing (or exactly NO_REPLY) when OK; only emit a short alert when broken.

Also see:

  • references/cron-agent-contract.md
  • references/pitfalls.md

Why this skill exists

Cron failures are rarely "logic bugs". In practice they're often:

  • brittle shell quoting (bash -lc '...' nested quotes)
  • command substitution surprises ($(...))
  • one-liners that hide escaping bugs (python -c "...")
  • cwd/env drift ("works locally, fails in cron")
  • pipelines that fail for the wrong reason (pipefail + head / SIGPIPE)

The fix is boring but effective: scripts-first + deterministic execution + silent-on-success.

Portability rules (still apply)

Even on POSIX, do not hardcode deployment-specific absolute paths tied to one machine.

Prefer:

  • repo-relative paths
  • environment variables you document
  • minimal wrappers that cd into the repo

Common failure patterns -> fixes

1) unexpected EOF while looking for matching ')'

Likely causes:

  • unclosed $(...) from command substitution
  • broken nested quotes in bash -lc ' ... '

Fix pattern:

  • Replace the whole multi-line shell block with a script.
  • Cron calls exactly one short command, for example:
  • python3 tools/.py

2) False failure from pipefail + head (SIGPIPE)

Symptom:

  • command exits non-zero even though the output you wanted is fine

Fix pattern:

  • avoid pipefail when piping into head
  • or better: do the filtering in a script (read only what you need)

3) "Works locally, fails in cron"

Common causes:

  • wrong working directory
  • missing env vars
  • different PATH

Fix pattern:

  • cd into the repo (or have the script do it)
  • keep dependencies explicit and documented

Git footgun: git push rejected (non-fast-forward)

Symptom:

  • ! [rejected] ... (non-fast-forward) when automation pushes to a long-lived PR/feature branch.

Conservative fix (no force-push):

  • On rejection, fetch the remote branch, transplant your new local commits onto it (cherry-pick), then retry push once.

Copy/paste hardening header (portable)

Use this near the top of a cron prompt (2 lines, low-noise):

  • Hardening (MUST): follow references/cron-agent-contract.md (scripts-first, deterministic cwd, silent-on-success).
  • Also apply the cron-worker-guardrails skill. If parsing/multi-step logic is needed, write/run a small tools/*.py script.

版本历史

共 1 个版本

  • v1.0.5 当前
    2026-03-29 02:54 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Proactive Agent

halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 836 📥 213,164
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 712 📥 243,858
productivity

context-clean-up

phenomenoner
适用场景:提示上下文出现膨胀(响应慢、成本上升、噪音记录)且需要分级问题列表和可逆方案时。不适用场景:……
★ 7 📥 2,952