ガイド - AIと自動化

Mac MiniでOpenClaw AIエージェントを24時間365日稼働させる方法

OpenClawは、WhatsApp、Telegram、Discordなどを介してタスクを自動化するオープンソースのAIエージェントで、ClaudeまたはGPTを利用します。Mac Mini M4は、常時稼働のホストとして理想的です。ローカルのApple Siliconによる処理、GPU追加料金ゼロ、そして月額$85の定額料金を実現します。

読了25分 2026年3月更新

1. なぜMac MiniでOpenClawを実行するのか?

クラウドVPSプロバイダーは、コンピューティング時間に応じて課金し、AI推論にはGPU追加料金を上乗せします。Mac Mini M4なら、月額$85の定額で専用のApple Siliconを利用できます。従量課金による予想外の請求はなく、フルSSHアクセスが可能で、OpenClawと並行してローカルLLMを実行し、推論コストをほぼゼロに抑えられます。

項目 クラウドVPS(AIプラン) Mac Mini M4(MyRemoteMac)
月額料金 $150–$400/月(GPU VPS) $85/月(定額)
ローカルLLMのサポート 追加料金/制限あり ネイティブ対応(Ollama、llama.cpp)
常時稼働 対応 対応(99.9% SLA)
Apple連携 なし iMessage、ショートカット、Automator
セットアップの複雑さ 低(SSHアクセス込み)
プライバシー 共有データセンター 専用ハードウェア

主なメリット: クラウドVPSとは異なり、Mac Mini M4はOllamaやllama.cppをApple Silicon上でネイティブに実行します。機密性の高いタスクではOpenClawをローカルLLMにルーティングし、複雑なクエリではClaudeにフォールバックできます——しかもトークン単位の課金は一切ありません。

2. 前提条件

始める前に、以下が揃っていることを確認してください。

  • MyRemoteMacMac Mini M4サーバー(月額$85から)
  • Mac Miniへの SSHアクセス(MyRemoteMacのサブスクリプションに付属)
  • Anthropic APIキー(Claude用)—console.anthropic.com で取得できます
  • エージェントを接続するための Telegram、Discord、またはWhatsApp のメッセージングアカウント
  • ターミナルコマンドJSON設定ファイルに関する基本的な知識

3. ステップ1:Mac Miniに接続してNode.jsをインストールする

まず、Mac Mini M4にSSH接続します。認証情報は、MyRemoteMacサーバーをセットアップした際に受け取っているはずです。

SSHで接続する

# Connect to your Mac Mini M4
ssh admin@your-server-ip

# Verify you're on Apple Silicon
uname -m
# Expected output: arm64

# Check macOS version
sw_vers
# ProductName:    macOS
# ProductVersion: 15.4

nvm(Node Version Manager)をインストールする

# Install nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# Load nvm into the current session
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Verify nvm is available
nvm --version
# 0.39.7

Node.js LTSをインストールする

Node.jsのバージョン管理には nvm をお勧めします——権限の問題を回避でき、アップグレードも簡単になります。

# Install the latest LTS version of Node.js
nvm install --lts

# Set it as the default for new sessions
nvm alias default node

# Verify the installation
node --version
# v22.x.x
npm --version
# 10.x.x

インストールを確認する

# Confirm Node.js is running on Apple Silicon
node -e "console.log(process.platform, process.arch)"
# darwin arm64

# Note the exact Node.js binary path (needed for launchd in Step 4)
which node
# /Users/admin/.nvm/versions/node/v22.14.0/bin/node

4. ステップ2:OpenClawをインストールしてClaude APIキーを構成する

Node.jsの準備ができたら、専用のプロジェクトディレクトリにOpenClawをインストールします。OpenClawはnpmパッケージとして配布されています。

OpenClawをインストールする

# Create a directory for your OpenClaw agent
mkdir -p ~/openclaw
cd ~/openclaw

# Initialize a Node.js project
npm init -y

# Install OpenClaw
npm install openclaw

# Create the logs directory
mkdir -p logs

設定ファイルを作成する

OpenClawは、config.jsonファイルから設定を読み込みます。プロジェクトディレクトリに作成してください。

# Create config.json in your project directory
cat > ~/openclaw/config.json << 'EOF'
{
  "model": "claude-sonnet-4-6",
  "apiKey": "sk-ant-YOUR_API_KEY_HERE",
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "YOUR_TELEGRAM_BOT_TOKEN"
    }
  },
  "maxHistory": 20,
  "systemPrompt": "You are a helpful assistant. Be concise and accurate."
}
EOF

sk-ant-YOUR_API_KEY_HERE を、console.anthropic.com で取得した実際のキーに置き換えてください。複雑なタスクには claude-sonnet-4-6 を、より高速で低コストな応答には claude-haiku-4-5 を使用できます。

エージェントをインタラクティブにテストする

# Start OpenClaw in interactive mode to test it
cd ~/openclaw
npx openclaw start --config ./config.json

# Expected output:
# [OpenClaw] Agent initialized with model: claude-sonnet-4-6
# [OpenClaw] Telegram channel connected
# [OpenClaw] Listening for messages...

# Press Ctrl+C to stop (you will set up the persistent service in Step 4)

5. ステップ3:メッセージングチャネルを接続する

OpenClawは、Telegram、Discord、WhatsApp、iMessage、Slack、Signalをサポートしています。最も簡単に設定できるチャネルはTelegramです——@BotFather でボットを作成します。

# Step 1: Open Telegram and search for @BotFather
# Step 2: Send /newbot and follow the prompts
# Step 3: Copy the token (format: 1234567890:AAF...)

# Test your bot token is valid:
curl -s "https://api.telegram.org/botYOUR_TOKEN/getMe"
# {"ok":true,"result":{"id":...,"first_name":"My Agent","username":"myagent_bot",...}}

Discordを接続する

Discordボットを接続するには、Discord Developer Portalでアプリケーションを作成し、必要な権限を付与します。

# In Discord Developer Portal (https://discord.com/developers/applications):
# 1. Create a New Application and give it a name
# 2. Go to Bot > Add Bot
# 3. Copy the Bot Token
# 4. Enable "Message Content Intent" under Privileged Gateway Intents
# 5. Under OAuth2 > URL Generator, select bot + Send Messages + Read Message History
# 6. Use the generated URL to invite the bot to your server

# Update your config.json to enable Discord:
# "discord": { "enabled": true, "token": "YOUR_DISCORD_BOT_TOKEN" }

6. ステップ4:永続的なlaunchdサービスとして実行する

24時間365日の稼働のためには、OpenClawが起動時に自動的に開始し、障害時に再起動する必要があります。macOSではこの目的にlaunchdを使用します——~/Library/LaunchAgents/ にサービスのplistを作成します。

launchd plistを作成する

以下を ~/openclaw/com.openclaw.agent.plist として保存します(admin を実際のユーザー名に置き換え、ステップ1のNode.jsパスに合わせて調整してください)。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.openclaw.agent</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/admin/.nvm/versions/node/v22.14.0/bin/node</string>
        <string>/Users/admin/openclaw/node_modules/.bin/openclaw</string>
        <string>start</string>
        <string>--config</string>
        <string>/Users/admin/openclaw/config.json</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/Users/admin/openclaw</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/Users/admin/openclaw/logs/openclaw.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/admin/openclaw/logs/openclaw-error.log</string>
</dict>
</plist>

サービスを有効化して開始する

# Save the plist to the LaunchAgents directory
# (Use your actual username instead of "admin")
cp ~/openclaw/com.openclaw.agent.plist ~/Library/LaunchAgents/

# Load and start the service
launchctl load ~/Library/LaunchAgents/com.openclaw.agent.plist
launchctl start com.openclaw.agent

サービスが稼働していることを確認する

# Check that the service is running
launchctl list | grep openclaw
# 12345   0   com.openclaw.agent
# (First column is the PID — a number means it's running)

# View live logs
tail -f ~/openclaw/logs/openclaw.log

# View error logs
tail -f ~/openclaw/logs/openclaw-error.log

OpenClawを更新する(ダウンタイムなし)

# Stop the service before updating
launchctl stop com.openclaw.agent

# Update OpenClaw to the latest version
cd ~/openclaw
npm update openclaw

# Restart the service
launchctl start com.openclaw.agent

# Confirm the new version is running
tail -5 ~/openclaw/logs/openclaw.log

7. よくある問題のトラブルシューティング

サービスが起動しない:「Cannot find module」

plist内のNode.jsの絶対パスが間違っているか、npmパッケージが不足しています。エラーログを確認して再インストールします。

# Check the error logs
cat ~/openclaw/logs/openclaw-error.log | tail -20

# Make sure to use the absolute Node.js binary path in the plist
which node
# /Users/admin/.nvm/versions/node/v22.14.0/bin/node

# Reinstall dependencies
cd ~/openclaw
npm install

Claude APIが401 Unauthorizedを返す

APIキーが設定されていない、間違っている、またはAnthropicアカウントのクレジット残高がありません。キーを確認します。

# Test your API key directly
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-haiku-4-5","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}'

# Expected: {"id":"msg_...","type":"message",...}
# If you get 401: check your key at console.anthropic.com

Telegramボットが応答しなくなる

ボットトークンが失効したか、サービスがクラッシュした可能性があります。トークンを確認して再起動します。

# Verify the bot token is still valid
curl -s "https://api.telegram.org/botYOUR_TOKEN/getMe"

# Restart the service
launchctl stop com.openclaw.agent
launchctl start com.openclaw.agent

# If the token was revoked, generate a new one via @BotFather (/mybots > API Token)

数日後にメモリ使用量が増大する

OpenClawは会話履歴をメモリに蓄積します。config.json の maxHistory を下げ、週次の再起動をスケジュールします。

# Reduce conversation history in config.json
# "maxHistory": 10  (default is 20 — lower values use less memory)

# Set up a weekly restart via cron
crontab -e
# Add this line to restart OpenClaw every Sunday at 3am:
# 0 3 * * 0 launchctl stop com.openclaw.agent; sleep 2; launchctl start com.openclaw.agent

# Monitor memory usage
ps aux | grep openclaw

8. クラウドVPSとのコスト比較

以下は、さまざまな利用レベルでAIエージェントを24時間365日稼働させた場合の現実的なコスト比較です。

ユースケース AIコール数/月 クラウドVPSのコスト MyRemoteMacのコスト 月間の節約額
パーソナルアシスタント 約500コール $120/月(基本的なGPU VPS) $85/月 $45/月
小規模チーム向けボット 約5,000コール $200/月 $85/月 $125/月
ローカルLLM + エージェント 無制限(ローカル) $350以上/月(GPU VPS) $85/月 $275以上/月
マルチエージェントシステム 10,000コール以上 $600以上/月 $229/月(M4 Pro) $371以上/月

結論: Mac Mini M4でOpenClawを実行すれば、あらゆるクラウドAI VPSよりも大幅に低コストです。さらに、Ollama経由でローカルLLMを動かせるネイティブなApple Siliconも手に入ります——機密性の低いタスクを無料のローカルモデルにルーティングすれば、API費用をさらに節約できます。

関連ガイド

AIエージェントを24時間365日稼働させる準備はできましたか?

専用のMac Mini M4をOpenClawのホストとして導入しましょう。月額$85から利用できます。

さらに詳しい情報をお探しですか?

ステップバイステップのセットアップ手順、設定リファレンス、トラブルシューティングについては、完全なドキュメントをご覧ください。

ドキュメントを開く →