Guida - AI & Automazione

Come eseguire l'agente AI OpenClaw 24/7 su un Mac Mini

OpenClaw è un agente AI open source che automatizza attività via WhatsApp, Telegram, Discord e altro — basato su Claude o GPT. Un Mac Mini M4 è l'host always-on ideale: elaborazione locale su Apple Silicon, zero sovrapprezzi GPU e un costo fisso di 85 $/mese.

25 min di lettura Aggiornato a marzo 2026

1. Perché eseguire OpenClaw su un Mac Mini?

I provider di VPS cloud fatturano in base al tempo di calcolo e aggiungono sovrapprezzi GPU per l'inferenza AI. Un Mac Mini M4 ti offre Apple Silicon dedicato a un costo fisso di 85 $/mese — nessuna sorpresa a consumo, accesso SSH completo e la possibilità di eseguire LLM locali insieme a OpenClaw con un costo di inferenza quasi nullo.

Caratteristica VPS cloud (tier AI) Mac Mini M4 (MyRemoteMac)
Costo mensile 150–400 $/mese (VPS GPU) 85 $/mese (tariffa fissa)
Supporto LLM locale Costo extra / limitato Nativo (Ollama, llama.cpp)
Disponibilità always-on Sì (SLA 99,9%)
Integrazioni Apple Nessuna iMessage, Shortcuts, Automator
Complessità di configurazione Media Bassa (accesso SSH incluso)
Privacy Datacenter condiviso Hardware dedicato

Vantaggio chiave: A differenza di un VPS cloud, il tuo Mac Mini M4 esegue Ollama o llama.cpp nativamente su Apple Silicon. Puoi indirizzare OpenClaw a un LLM locale per attività sensibili, poi ripiegare su Claude per query complesse — il tutto senza pagare per token.

2. Prerequisiti

Prima di iniziare, assicurati di avere quanto segue:

  • Un server Mac Mini M4 di MyRemoteMac (da 85 $/mese)
  • Accesso SSH al tuo Mac Mini (incluso nel tuo abbonamento MyRemoteMac)
  • Una chiave API Anthropic (per Claude) — ottienila su console.anthropic.com
  • Un account di messaggistica su Telegram, Discord o WhatsApp per collegare il tuo agente
  • Familiarità di base con comandi da terminale e file di configurazione JSON

3. Passo 1: Connettiti al tuo Mac Mini e installa Node.js

Per prima cosa, connettiti al tuo Mac Mini M4 via SSH. Hai ricevuto le tue credenziali quando hai configurato il tuo server MyRemoteMac.

Connettiti via 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

Installa 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

Installa Node.js LTS

Consigliamo nvm per gestire le versioni di Node.js — evita problemi di permessi e rende banali gli aggiornamenti:

# 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

Verifica l'installazione

# 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. Passo 2: Installa OpenClaw e configura la chiave API Claude

Con Node.js pronto, installa OpenClaw in una directory di progetto dedicata. OpenClaw viene distribuito come pacchetto npm.

Installa 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

Crea il file di configurazione

OpenClaw legge le sue impostazioni da un file config.json. Creane uno nella tua directory di progetto:

# 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

Sostituisci sk-ant-YOUR_API_KEY_HERE con la tua chiave effettiva da console.anthropic.com. Puoi usare claude-sonnet-4-6 per attività complesse o claude-haiku-4-5 per risposte più veloci ed economiche.

Testa l'agente in modo interattivo

# 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. Passo 3: Collega i canali di messaggistica

OpenClaw supporta Telegram, Discord, WhatsApp, iMessage, Slack e Signal. Il canale più semplice da configurare è Telegram — crea un bot tramite @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",...}}

Collega Discord

Per collegare un bot Discord, crea un'applicazione nel Discord Developer Portal e concedile i permessi necessari:

# 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. Passo 4: Esegui come servizio launchd persistente

Per il funzionamento 24/7, OpenClaw deve avviarsi automaticamente all'avvio e riavviarsi in caso di errore. macOS usa launchd a questo scopo — crea un plist di servizio in ~/Library/LaunchAgents/.

Crea il plist launchd

Salva quanto segue come ~/openclaw/com.openclaw.agent.plist (sostituisci admin con il tuo nome utente effettivo e adatta il percorso di Node.js dal Passo 1):

<?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>

Abilita e avvia il servizio

# 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

Verifica che il servizio sia in esecuzione

# 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

Aggiorna OpenClaw (zero downtime)

# 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. Risoluzione dei problemi comuni

Il servizio non si avvia: "Cannot find module"

Il percorso assoluto di Node.js nel plist è errato oppure mancano pacchetti npm. Controlla il log degli errori e reinstalla:

# 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

L'API Claude restituisce 401 Unauthorized

La tua chiave API manca, è errata o il tuo account Anthropic non ha crediti residui. Verifica la chiave:

# 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

Il bot Telegram smette di rispondere

Il token del bot potrebbe essere stato revocato oppure il servizio è andato in crash. Controlla il token e riavvia:

# 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)

Uso elevato della memoria dopo diversi giorni

OpenClaw accumula la cronologia delle conversazioni in memoria. Riduci maxHistory in config.json e pianifica un riavvio settimanale:

# 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. Analisi dei costi vs. VPS cloud

Ecco un confronto realistico dei costi per eseguire un agente AI 24/7 a diversi livelli di utilizzo:

Caso d'uso Chiamate AI/mese Costo VPS cloud Costo MyRemoteMac Risparmio mensile
Assistente personale ~500 chiamate 120 $/mese (VPS GPU base) 85 $/mese 45 $/mese
Bot per piccolo team ~5.000 chiamate 200 $/mese 85 $/mese 125 $/mese
LLM locale + agente Illimitate (locale) 350+ $/mese (VPS GPU) 85 $/mese 275+ $/mese
Sistema multi-agente 10.000+ chiamate 600+ $/mese 229 $/mese (M4 Pro) 371+ $/mese

In sintesi: Eseguire OpenClaw su un Mac Mini M4 è notevolmente più economico di qualsiasi VPS cloud AI. Ottieni anche Apple Silicon nativo per LLM locali tramite Ollama — indirizza le attività non sensibili a un modello locale gratuito e risparmia ancora di più sui costi API.

Guide correlate

Pronto a eseguire il tuo agente AI 24/7?

Distribuisci un Mac Mini M4 dedicato come tuo host OpenClaw. A partire da 85 $/mese.

Cerchi maggiori dettagli?

Consulta la documentazione completa per guide passo passo, riferimenti di configurazione e risoluzione dei problemi.

Apri la documentazione →