Gateway Idle Shutdown for Openclaw

An automated monitoring service that detects inactivity and shuts down the OpenClaw Gateway to optimize system resources.

yu200512
v1.0.0
Apr 28, 2026
0
702
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install idle-shutdown

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install idle-shutdown using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Gateway Idle Shutdown?

Gateway Idle Shutdown is a specialized utility within the Openclaw Skills ecosystem designed to monitor user session activity in real-time. It acts as an intelligent watchdog for your AI infrastructure, ensuring that the OpenClaw Gateway only consumes system resources when active communication is occurring between users and the bot. By tracking the modification times of session transcript files, it accurately determines when a gateway has become redundant.

This skill is essential for developers and system administrators who want to maintain high efficiency in their AI deployments. It bridges the gap between availability and resource conservation, providing a robust solution for managing the lifecycle of gateway processes without manual oversight. Implementing this through Openclaw Skills ensures your environment remains lean, cost-effective, and environmentally friendly.

Gateway Idle Shutdown Use Cases

  • Automatically stop the gateway during overnight periods or weekends when user activity is zero.
  • Reduce compute costs on metered cloud platforms by terminating unused processes.
  • Manage resource contention on low-power devices like Raspberry Pi or home servers.
  • Ensure clean service termination in multi-agent environments where manual shutdowns are easily forgotten.

How Gateway Idle Shutdown Works

  1. The script initiates a polling loop that inspects the session transcript directory every 10 seconds.
  2. It checks the metadata (mtime) of session files associated with QQBot, channels, or direct messages.
  3. The system compares the timestamp of the most recent activity against a user-defined idle threshold (defaulting to 120 seconds).
  4. If the threshold is exceeded with no new activity detected, the script triggers the openclaw gateway stop command.
  5. The systemd service ensures the watcher process starts and stops in synchronization with the gateway itself.

Gateway Idle Shutdown Setup

# 1. Copy the script to your workspace
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 << '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
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

Gateway Idle Shutdown Data Schema & Taxonomy

The skill manages its state and configuration through the following data structures:

Variable Default Value Role
IDLE_SECONDS 120 The duration of inactivity required before triggering shutdown.
POLL_SECONDS 10 Frequency of session file checks.
SESSIONS_DIR ~/.openclaw/agents/main/sessions The source of truth for user activity timestamps.
LOG_FILE ~/.openclaw/logs/idle-shutdown.log Continuous audit trail of monitoring activity and shutdown events.
OPENCLAW_BIN openclaw The path to the executable responsible for gateway management.

Gateway Idle Shutdown Advanced Features

  • Systemd BindsTo Integration: Ensures the watcher never runs as an orphaned process if the gateway is manually stopped.
  • Flexible Environment Variables: Allows for per-environment tuning of idle sensitivity and polling frequency.
  • Automated Recovery: The service includes a Restart=on-failure policy to ensure monitoring resilience.
  • Low-Overhead Polling: Uses efficient bash-based file inspection to maintain a negligible CPU footprint.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*