技能详情(站内镜像,无评论)
作者:Joey Luo @darwin7381
许可证:MIT-0
MIT-0 ·免费使用、修改和重新分发。无需归因。
版本:v1.0.0
统计:⭐ 0 · 114 · 0 current installs · 0 all-time installs
⭐ 0
安装量(当前) 0
🛡 VirusTotal :良性 · OpenClaw :良性
Package:darwin7381/openclaw-tmux-persistent-process
安全扫描(ClawHub)
- VirusTotal :良性
- OpenClaw :良性
OpenClaw 评估
The skill is an instruction-only guide for using tmux to keep processes alive; its instructions and requirements are coherent with that purpose, with only minor bookkeeping concerns to note.
目的
The SKILL.md clearly documents using tmux to keep long-lived processes running. Registry metadata lists no required binaries, but the instructions explicitly require tmux 2.6+ — a small mismatch. Otherwise the commands and guidance align with the stated purpose (dev servers, tunnels, workers).
说明范围
All runtime instructions are limited to managing tmux sessions (create, list, capture-pane, send-keys, kill-session/kill-server) and using a dedicated socket. Tunnel examples (ngrok, ssh -R) are expected for the use-cases. The instructions do not ask the agent to read unrelated files, other env vars, or to exfiltrate data.
安装机制
This is instruction-only (no install spec, no code written to disk), which is low-risk. The SKILL.md suggests how to install tmux via package managers, which is appropriate.
证书
The skill requests no environment variables or credentials. It notes that tmux inherits the environment at creation time and shows how to set env vars for sessions — appropriate for the purpose. There is no unnecessary request for unrelated secrets.
持久
The skill is not force-enabled (always: false) and does not request persistent platform privileges. Its guidance intentionally creates long-lived processes, which is the intended behavior and not a platform privilege escalation.
综合结论
This skill is basically a how-to for running tmux-based persistent processes and is coherent with that goal. Before installing/use: 1) Ensure tmux 2.6+ is available (the registry metadata should list tmux as a required binary — consider updating that). 2) Prefer a per-user socket path (for example under /run/user/$UID or a directory you own) or make sure /tmp/openclaw-tmux is created with restrictive ownership/permissions to avoid local symlin…
安装(复制给龙虾 AI)
将下方整段复制到龙虾中文库对话中,由龙虾按 SKILL.md 完成安装。
请把本段交给龙虾中文库(龙虾 AI)执行:为本机安装 OpenClaw 技能「OpenClaw Tmux Persistent Process」。简介:Run programs that survive OpenClaw exec session cleanup and gateway restarts vi…。
请 fetch 以下地址读取 SKILL.md 并按文档完成安装:https://raw.githubusercontent.com/openclaw/skills/refs/heads/main/skills/darwin7381/openclaw-tmux-persistent-process/SKILL.md
(来源:yingzhi8.cn 技能库)
SKILL.md
---
name: openclaw-tmux-persistent-process
description: >
Run programs that survive OpenClaw exec session cleanup and gateway restarts via tmux.
Use when you need long-running servers, dev servers, tunnels (ngrok/cloudflared),
coding agents, or any process that must outlive the current exec session.
Solves: exec background processes getting SIGKILL on session cleanup.
Recommended for all OpenClaw users running any long-lived process.
---
# OpenClaw Tmux Persistent Process
Run programs that survive OpenClaw exec session cleanup and gateway restarts.
## Why every OpenClaw user should have this
OpenClaw runs shell commands via `exec`. But exec has a critical limitation that most users don't realize until something breaks:
- **Background processes are tied to the exec session.** When the session cleans up (idle timeout, context compaction, or gateway restart), all background processes receive SIGKILL and die immediately.
- **Gateway restarts kill everything.** Updates, config changes, or `openclaw gateway restart` — all running exec processes are gone.
- **No warning.** Your tunnel, dev server, or build task just silently disappears.
This means anything you expect to keep running — a tunnel for a client demo, a dev server, a long build — can die at any moment without notice.
**The solution:** Use **tmux** to create virtual terminals completely decoupled from the exec lifecycle. Programs in tmux survive gateway restarts, exec cleanup, and session timeouts. tmux runs independently of OpenClaw — even if the gateway goes down, your processes keep running.
**Rule of thumb:** If a command might run longer than 2 minutes, use tmux.
---
## Socket convention
All operations use a dedicated socket to avoid interfering with the user's own tmux:
```bash
SOCK="/tmp/openclaw-tmux/openclaw.sock"
mkdir -p /tmp/openclaw-tmux
```
## Start a process
```bash
SESSION="my-server"
# Check if already running
if tmux -S "$SOCK" has-session -t "$SESSION" 2>/dev/null; then
echo "already running"
else
tmux -S "$SOCK" new -d -s "$SESSION"
"cd /path/to/project && npm run dev"
echo "started"
fi
```
## Monitor
```bash
# List all sessions
tmux -S "$SOCK" list-sessions
# View last 30 lines of output
tmux -S "$SOCK" capture-pane -t "$SESSION" -p -S -30
# Check if process is idle (back to shell prompt)
tmux -S "$SOCK" capture-pane -t "$SESSION" -p -S -3
| grep -qE '$s*$|❯' && echo "IDLE" || echo "RUNNING"
```
## Interact
```bash
# Send a command
tmux -S "$SOCK" send-keys -t "$SESSION" "command" Enter
# Send literal text (recommended, no special key parsing)
tmux -S "$SOCK" send-keys -t "$SESSION" -l -- "literal text"
tmux -S "$SOCK" send-keys -t "$SESSION" Enter
# Ctrl+C to interrupt
tmux -S "$SOCK" send-keys -t "$SESSION" C-c
```
## Stop / cleanup
```bash
# Kill one session
tmux -S "$SOCK" kill-session -t "$SESSION"
# Kill all
tmux -S "$SOCK" kill-server
# Clean stale socket
rm -f "$SOCK"
```
## Start interactive programs (wait for ready)
For programs that need startup time (e.g. coding agents, REPLs):
```bash
SESSION="my-task"
tmux -S "$SOCK" new -d -s "$SESSION"
tmux -S "$SOCK" send-keys -t "$SESSION" "cd ~/project && node" Enter
# Wait for prompt before sending commands
for i in $(seq 1 15); do
OUTPUT=$(tmux -S "$SOCK" capture-pane -t "$SESSION" -p -S -5)
if echo "$OUTPUT" | grep -qE '❯|>s*$|ready'; then
break
fi
sleep 1
done
# Now safe to send input
tmux -S "$SOCK" send-keys -t "$SESSION" -l "your command"
tmux -S "$SOCK" send-keys -t "$SESSION" Enter
```
## Common use cases
| Use case | Session name | Command example |
|----------|-------------|-----------------|
| Dev server | `dev-server` | `npm run dev` |
| Tunnel (ngrok) | `tunnel-ngrok` | `ngrok http 3000` |
| Tunnel (localhost.run) | `tunnel-lr` | `ssh -R 80:localhost:3000 nokey@localhost.run` |
| Background worker | `worker` | `python worker.py` |
| Build task | `build-app` | `npm run build` |
## Session naming
Lowercase + hyphens. No spaces.
```
dev-server — development servers
tunnel-{name} — tunnels (ngrok, cloudflared, etc.)
build-{project} — build tasks
worker-{name} — background workers
```
## Important notes
- **Reboot = gone.** tmux doesn't survive system restarts. Re-create sessions after reboot.
- **Scrollback limit.** Default 2000 lines. Increase with: `tmux set-option -t "$SESSION" history-limit 10000`
- **Socket stale.** If `list-sessions` says "error connecting", delete the socket and recreate.
- **Environment.** tmux inherits env at creation time. Set vars in the command: `tmux new -d -s name "export KEY=val && cmd"`
- **No conflict.** Dedicated socket means zero interference with user's own tmux.
## Requirements
- **tmux 2.6+** (for `send-keys -l` literal mode)
- Check: `tmux -V`
- Install: `brew install tmux` (macOS) or `apt install tmux` (Linux)