Install
openclaw skills install @yu200512/idle-shutdownMonitors user session idleness and automatically stops the OpenClaw Gateway after a configurable idle period to save resources and costs.
openclaw skills install @yu200512/idle-shutdownMonitors session activity between users and the bot, and automatically stops the OpenClaw Gateway when all sessions have been idle continuously beyond the configured threshold.
~/.openclaw/agents/main/sessions/) every 10 seconds for their last modification time (mtime)openclaw gateway stop~/.openclaw/logs/idle-shutdown.logsleep-based polling uses negligible system resources, making it suitable for low-power devices and headless servers alike.# 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 << '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
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 |
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
openclaw-gateway.service (BindsTo + PartOf)