はじめに
OpenClaw のコマンドラインツール openclaw は、AI ゲートウェイを管理する主要なエントリーポイントです。設定ファイル以外にも、多くの動作を起動パラメータで一時的にオーバーライドまたは調整できます。本記事では、openclaw のすべてのサブコマンドとパラメータオプションを完全にリストアップし、さまざまなシーンで柔軟に活用できるようにします。
グローバルオプション
以下のオプションはすべてのサブコマンドに適用されます。
openclaw [グローバルオプション] <サブコマンド> [サブコマンドオプション]
| オプション | 短縮形 | 説明 |
|---|---|---|
--config <path> |
-c |
設定ファイルのパスを指定、デフォルトの ~/.openclaw/openclaw.json をオーバーライド |
--log-level <level> |
-l |
ログレベル:debug、info、warn、error |
--quiet |
-q |
サイレントモード、エラーメッセージのみ出力 |
--verbose |
-v |
詳細出力モード、--log-level debug と同等 |
--no-color |
ターミナルのカラー出力を無効化 | |
--version |
-V |
バージョン番号を表示 |
--help |
-h |
ヘルプ情報を表示 |
例
# カスタム設定ファイルで起動
openclaw -c /etc/openclaw/production.json gateway
# デバッグモードで実行
openclaw -v gateway
# バージョンを確認
openclaw --version
gateway コマンド
gateway は最も重要なコマンドで、AI ゲートウェイサービスを起動するために使用します。
openclaw gateway [オプション]
| オプション | 短縮形 | デフォルト値 | 説明 |
|---|---|---|---|
--port <number> |
-p |
18789 |
ゲートウェイリスニングポート |
--host <address> |
-H |
127.0.0.1 |
リスニングアドレス |
--daemon |
-d |
デーモンプロセスモードで実行(バックグラウンド実行) | |
--pid-file <path> |
~/.openclaw/openclaw.pid |
PID ファイルパス | |
--workers <number> |
-w |
0(自動) |
ワーカースレッド数 |
--timeout <ms> |
-t |
120000 |
リクエストタイムアウト(ミリ秒) |
--no-dashboard |
内蔵 Dashboard を起動しない | ||
--channels <list> |
すべて | 指定されたチャンネルのみ有効化、カンマ区切り | |
--dry-run |
設定を検証しシミュレーション起動、実際には実行しない |
よくある使い方
# デフォルト起動
openclaw gateway
# ポートとアドレスを指定
openclaw gateway --port 8080 --host 0.0.0.0
# バックグラウンド実行
openclaw gateway --daemon
# Telegram と Discord チャンネルのみ有効化
openclaw gateway --channels telegram,discord
# 設定が正しいか検証(実際には起動しない)
openclaw gateway --dry-run
デーモンプロセス管理
--daemon モードで起動した後、以下のコマンドで管理できます。
# 実行状態の確認
openclaw status
# グレースフル停止
openclaw stop
# 強制停止
openclaw stop --force
# 再起動
openclaw restart
# 設定のホットリロード(接続を中断しない)
openclaw reload
dashboard コマンド
Web Dashboard を単独で起動し、ゲートウェイサービスは起動しません。
openclaw dashboard [オプション]
| オプション | 短縮形 | デフォルト値 | 説明 |
|---|---|---|---|
--port <number> |
-p |
18789 |
Dashboard ポート |
--gateway <url> |
-g |
http://localhost:18789 |
接続先のゲートウェイアドレス |
--open |
-o |
起動後に自動的にブラウザを開く | |
--no-auth |
パスワード認証をスキップ(開発環境のみ) |
例
# 起動してブラウザを開く
openclaw dashboard --open
# リモートゲートウェイに接続
openclaw dashboard --gateway https://remote-server:18789
# カスタムポートを使用
openclaw dashboard --port 3000
doctor コマンド
診断ツール。設定、依存関係、接続状態をチェックします。
openclaw doctor [オプション]
| オプション | 説明 |
|---|---|
--config-only |
設定ファイルの構文と必須項目のみチェック |
--connectivity |
すべての設定済みチャンネルとモデルのネットワーク接続性をテスト |
--remote |
外部アクセスが正常かテスト(webhookBase の設定が必要) |
--fix |
修正可能な問題を自動修正(不足しているディレクトリの作成など) |
出力例
$ openclaw doctor
OpenClaw 診断レポート
==================
設定ファイル
✓ 設定ファイルの形式は正しい
✓ すべての必須項目が設定済み
モデル接続
✓ Claude API 接続正常 (遅延: 230ms)
✓ OpenAI API 接続正常 (遅延: 180ms)
✗ Ollama 接続失敗: ECONNREFUSED localhost:11434
チャンネル状態
✓ Telegram Bot 認証済み
✓ Discord Bot ログイン済み
- WhatsApp 未設定
システム環境
✓ Node.js v20.11.0
✓ ディスク容量十分 (空き: 50GB)
✓ メモリ十分 (空き: 4.2GB)
問題: 1
1. Ollama サービスが未起動です。Ollama を起動するか、このモデル設定を無効にしてください
session コマンド
会話セッションデータを管理します。
openclaw session <サブコマンド> [オプション]
| サブコマンド | 説明 |
|---|---|
list |
すべてのセッションを一覧表示 |
stats |
セッション統計情報を表示 |
clear |
セッションデータをクリア |
export |
セッションをエクスポート |
compact |
手動で圧縮をトリガー |
trim |
履歴を指定件数にトリム |
よく使う操作
# すべてのアクティブセッションを一覧表示
openclaw session list
# Agent でフィルタ
openclaw session list --agent default
# 特定セッションの詳細統計を表示
openclaw session stats --session telegram_123456
# 特定セッションをクリア
openclaw session clear --session telegram_123456
# 特定 Agent のすべてのセッションをクリア
openclaw session clear --agent default --all
# セッションを JSON としてエクスポート
openclaw session export --session telegram_123456 --format json
# 手動圧縮
openclaw session compact --session telegram_123456
# 最新20件のメッセージを保持
openclaw session trim --session telegram_123456 --keep 20
mobile コマンド
モバイルデバイスのペアリングを管理します。
openclaw mobile <サブコマンド> [オプション]
| サブコマンド | 説明 |
|---|---|
pair |
ペアリングコードまたは QR コードを生成 |
list |
ペアリング済みデバイスを一覧表示 |
remove |
デバイスを削除 |
例
# テキストペアリングコードを生成
openclaw mobile pair --generate
# QR コードを生成
openclaw mobile pair --qrcode
# デバイスを一覧表示
openclaw mobile list
# 指定デバイスを削除
openclaw mobile remove mob_a3f2c1d8
# すべてのデバイスを削除
openclaw mobile remove --all
config コマンド
設定の表示と管理を行います。
openclaw config <サブコマンド> [オプション]
| サブコマンド | 説明 |
|---|---|
--dump |
現在有効な完全な設定を出力 |
--get <key> |
指定した設定項目の値を取得 |
--set <key> <value> |
設定項目を設定 |
--edit |
システムエディターで設定ファイルを開く |
--init |
デフォルト設定ファイルを生成 |
--validate |
設定ファイルを検証 |
例
# 完全な設定を表示
openclaw config --dump
# 特定の設定値を取得
openclaw config --get gateway.port
# 設定値を変更
openclaw config --set gateway.port 8080
# デフォルト設定を初期化
openclaw config --init
# エディターを開く
openclaw config --edit
access コマンド
アクセス制御と権限を管理します。
openclaw access <サブコマンド> [オプション]
| サブコマンド | 説明 |
|---|---|
allow <id> |
ユーザーまたはグループをホワイトリストに追加 |
deny <id> |
ユーザーまたはグループをブラックリストに追加 |
remove <id> |
ホワイトリストまたはブラックリストから削除 |
list |
現在のホワイトリストとブラックリストを一覧表示 |
pair-code |
ペアリングコードを生成 |
log |
アクセスログを表示 |
例
# ユーザーをホワイトリストに追加
openclaw access allow tg:123456789
# ユーザーをブロック
openclaw access deny tg:999888777
# ホワイトリストを表示
openclaw access list
# アクセスログを表示
openclaw access log --tail 50
media コマンド
メディアファイルキャッシュを管理します。
openclaw media <サブコマンド>
| サブコマンド | 説明 |
|---|---|
cleanup |
メディアキャッシュをクリーンアップ |
stats |
キャッシュ統計を表示 |
環境変数
一部の起動パラメータは環境変数でも設定できます。環境変数の優先度は設定ファイルより高いですが、コマンドラインパラメータより低くなります。
| 環境変数 | 対応パラメータ |
|---|---|
OPENCLAW_CONFIG |
--config |
OPENCLAW_PORT |
--port |
OPENCLAW_HOST |
--host |
OPENCLAW_LOG_LEVEL |
--log-level |
OPENCLAW_DASHBOARD_PASSWORD |
Dashboard パスワード |
OPENCLAW_CLAUDE_API_KEY |
Claude API キー |
OPENCLAW_OPENAI_API_KEY |
OpenAI API キー |
OPENCLAW_TELEGRAM_TOKEN |
Telegram Bot Token |
優先順位(高い順):コマンドラインパラメータ > 環境変数 > 設定ファイル > デフォルト値。
systemd サービス設定
Linux サーバーでは、systemd で OpenClaw を管理することを推奨します。
# /etc/systemd/system/openclaw.service
[Unit]
Description=OpenClaw AI Gateway
After=network.target
[Service]
Type=simple
User=openclaw
WorkingDirectory=/home/openclaw
ExecStart=/usr/local/bin/openclaw gateway --port 18789 --host 0.0.0.0
ExecReload=/usr/local/bin/openclaw reload
Restart=always
RestartSec=5
Environment=OPENCLAW_CONFIG=/etc/openclaw/openclaw.json
[Install]
WantedBy=multi-user.target
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclaw
まとめ
openclaw コマンドラインツールは、ゲートウェイの起動からセッション管理、問題の診断から権限設定まで、完全な機能セットを提供します。日常的な使用では、gateway、doctor、session が最もよく使われる 3 つのコマンドです。コマンドラインパラメータの優先度は設定ファイルより高いことを覚えておいてください——つまり、設定ファイルを変更せずにパラメータでゲートウェイの動作を一時的に調整でき、デバッグやテストに非常に便利です。