← 返回 Skills 市场
yu200512

Idle-shutdown

作者 yu200512 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
51
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install idle-shutdown
功能描述
Monitors user session idleness and automatically stops the OpenClaw Gateway after a configurable idle period to save resources and costs.
使用说明 (SKILL.md)

Gateway Idle Shutdown

Monitors session activity between users and the bot, and automatically stops the OpenClaw Gateway when all sessions have been idle continuously beyond the configured threshold.

How It Works

  • Polls session transcript files (~/.openclaw/agents/main/sessions/) every 10 seconds for their last modification time (mtime)
  • Preferentially matches QQBot/channel/direct related session files
  • When the latest mtime is older than the threshold (default 120 seconds), executes openclaw gateway stop
  • Logs are written to ~/.openclaw/logs/idle-shutdown.log

Benefits

  • Resource Savings — Automatically stops the Gateway when no one is using it, freeing CPU and memory that would otherwise be wasted during idle periods.
  • Cost Reduction — On metered or cloud-hosted environments, shutting down idle services reduces compute costs by avoiding charges for unused uptime.
  • Energy Efficiency — Reduces power consumption by ensuring services only run when actually needed, lowering your carbon footprint.
  • Zero Manual Intervention — Once configured, the watcher runs autonomously with systemd; you never need to remember to shut down the Gateway manually.
  • Seamless Lifecycle Integration — The systemd watcher is bound to the Gateway service (BindsTo + PartOf), so it starts and stops in lockstep — no orphaned watcher processes and no stale state.
  • Configurable & Forgiving — Idle threshold, polling interval, session directory, and binary path are all controlled via environment variables; the watcher retries on failure instead of exiting abruptly.
  • Lightweight Footprint — A simple bash script with sleep-based polling uses negligible system resources, making it suitable for low-power devices and headless servers alike.

Installation

# 1. Copy the script
cp scripts/idle-shutdown.sh ~/.openclaw/workspace/scripts/
chmod +x ~/.openclaw/workspace/scripts/idle-shutdown.sh

# 2. Create the systemd service file
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/openclaw-idle-watch.service \x3C\x3C 'EOF'
[Unit]
Description=OpenClaw idle gateway shutdown watcher
After=openclaw-gateway.service
BindsTo=openclaw-gateway.service
PartOf=openclaw-gateway.service

[Service]
Type=simple
ExecStart=%h/.openclaw/workspace/scripts/idle-shutdown.sh
Restart=on-failure
RestartSec=10s
Environment=HOME=%h
# Adjust this PATH if your openclaw binary lives elsewhere
Environment=PATH=%h/.local/bin:%h/bin:/usr/local/bin:/usr/bin:/bin
Environment=OPENCLAW_BIN=openclaw

[Install]
WantedBy=default.target
EOF

# 3. Enable and start the service
systemctl --user daemon-reload
systemctl --user enable openclaw-idle-watch.service
systemctl --user start openclaw-idle-watch.service

Configuration

Customize behavior via environment variables:

Variable Default Description
IDLE_SECONDS 120 Idle threshold (seconds)
POLL_SECONDS 10 Polling interval (seconds)
SESSIONS_DIR ~/.openclaw/agents/main/sessions Session directory
LOG_FILE ~/.openclaw/logs/idle-shutdown.log Log file path
OPENCLAW_BIN openclaw openclaw binary path

Uninstallation

systemctl --user stop openclaw-idle-watch.service
systemctl --user disable openclaw-idle-watch.service
rm ~/.config/systemd/user/openclaw-idle-watch.service
rm ~/.openclaw/workspace/scripts/idle-shutdown.sh

Service Lifecycle

  • The watcher is bound to openclaw-gateway.service (BindsTo + PartOf)
  • Gateway starts → Watcher starts automatically
  • Gateway stops → Watcher stops automatically
  • Watcher triggers on idle → Gateway is stopped → Watcher stops along with Gateway
安全使用建议
This skill appears to do exactly what it says: a lightweight, user-level watcher that stops the OpenClaw Gateway when session files are idle. Before installing: (1) inspect the script (it's small and readable) and confirm the SESSIONS_DIR and OPENCLAW_BIN values match your setup; (2) be aware it will stop your gateway automatically — test with a long IDLE_SECONDS in a non-production environment first; (3) systemd user services and 'stat -c' behavior are Linux-specific — if you run macOS or a different init system, the unit/script may not work as-is; (4) consider setting conservative defaults (larger IDLE_SECONDS) and monitoring the log at ~/.openclaw/logs/idle-shutdown.log after enabling. If you don't want automated shutdowns, do not enable the systemd service.
功能分析
Type: OpenClaw Skill Name: idle-shutdown Version: 1.0.0 The skill bundle provides a legitimate utility for monitoring OpenClaw Gateway session activity and automatically shutting down the service after a configurable idle period to save resources. The implementation consists of a transparent bash script (scripts/idle-shutdown.sh) and standard systemd service configuration instructions in SKILL.md, with no evidence of malicious intent, data exfiltration, or unauthorized execution.
能力评估
Purpose & Capability
The name/description match the actual behavior: a bash watcher that checks mtime of session transcripts under ~/.openclaw/agents/main/sessions and runs 'openclaw gateway stop' when idle. It does not request unrelated credentials or binaries.
Instruction Scope
SKILL.md instructs copying the provided script and creating a user systemd service; the runtime instructions only access the session directory, the openclaw binary, and write logs to the user's home. There are no instructions to read unrelated files, transmit data externally, or elevate privileges.
Install Mechanism
No installer or remote downloads are used — this is an instruction-only skill plus a local bash script. The install steps are limited to copying the script and creating a user systemd unit (no external code fetch).
Credentials
The skill requests no credentials and only uses standard environment variables (HOME, optional OPENCLAW_BIN, and user-configurable IDLE/POLL/paths). Writing logs to ~/.openclaw is expected for this purpose and is proportional.
Persistence & Privilege
The skill persists by creating a systemd --user service (normal for a watcher). 'always' is false and the service runs as the local user, not system-wide. This means it will stop the gateway autonomously when conditions are met — confirm you want an automated shutdown behavior.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install idle-shutdown
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /idle-shutdown 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of gateway-idle-shutdown. - Monitors OpenClaw Gateway session activity and automatically shuts down the Gateway after a configurable idle period. - Provides a lightweight, systemd-integrated watcher with customizable thresholds and robust lifecycle management. - Reduces resource usage, operational costs, and manual intervention by automating idle Gateway shutdowns. - Configuration via environment variables; simple installation and removal instructions included.
元数据
Slug idle-shutdown
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Idle-shutdown 是什么?

Monitors user session idleness and automatically stops the OpenClaw Gateway after a configurable idle period to save resources and costs. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 51 次。

如何安装 Idle-shutdown?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install idle-shutdown」即可一键安装,无需额外配置。

Idle-shutdown 是免费的吗?

是的,Idle-shutdown 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Idle-shutdown 支持哪些平台?

Idle-shutdown 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Idle-shutdown?

由 yu200512(@yu200512)开发并维护,当前版本 v1.0.0。

💬 留言讨论