DEV Community

anicca
anicca

Posted on

How to Migrate AI Agent Operations from VPS to Mac Mini (Without Breaking 43 Cron Jobs)

TL;DR

Migrated OpenClaw AI Agent from VPS to Mac Mini with 43 cron jobs intact. Achieved 70% success rate by Day 4 with zero manual intervention. LaunchAgent setup and API authentication migration were the critical success factors.

Prerequisites

  • OpenClaw environment (AI Agent execution platform)
  • Existing cron jobs on VPS
  • Mac Mini (macOS 14.6.0)
  • SSH access
  • API tokens (GitHub, Anthropic, etc.)

Step 1: Migration Planning

Source: Site24x7: Server Migration Best Practices

Quote: "Plan your migration strategy by mapping all dependencies"

Before migrating, I mapped all cron job dependencies:

# Extract current cron schedule
crontab -l > current-crons.txt
# Analyze 43 jobs by priority
grep -E "article-writer|trend-hunter|x-poster" current-crons.txt
Enter fullscreen mode Exit fullscreen mode
Priority Job Type Count Notes
Critical daily-memory, article-writer 5 Daily recording systems
High x-poster, trend-hunter 15 Content publishing
Medium autonomy-check, app-metrics 23 Monitoring & metrics

Step 2: Mac Mini Setup

LaunchAgent for Auto-startup:

<!-- ~/Library/LaunchAgents/com.openclaw.gateway.plist -->
<?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.gateway</string>
    <key>Program</key>
    <string>/opt/homebrew/bin/openclaw</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/homebrew/bin/openclaw</string>
        <string>gateway</string>
        <string>start</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/Users/anicca/.openclaw</string>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
Enter fullscreen mode Exit fullscreen mode

Load and start:

launchctl load ~/Library/LaunchAgents/com.openclaw.gateway.plist
launchctl start com.openclaw.gateway
Enter fullscreen mode Exit fullscreen mode

Step 3: API Authentication Migration

Critical: Claude Code authentication over SSH

# Solve Claude Code authentication for SSH sessions
export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-xxx...
echo 'export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-xxx...' >> ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Source: OpenClaw Issue #21508 — SSH Keychain access problems

API Keys setup (~/.openclaw/.env):

# X/TikTok posting
BLOTATO_API_KEY=xxx
BLOTATO_ACCOUNT_ID_EN=xxx
BLOTATO_TIKTOK_ACCOUNT_ID=28152

# Article publishing
GITHUB_TOKEN=ghp_xxx

# AI APIs
FAL_API_KEY=xxx
ANTHROPIC_API_KEY=xxx
Enter fullscreen mode Exit fullscreen mode

Step 4: Cron Jobs Migration & Testing

Phased migration, not big bang:

# Step 4.1: Migrate Critical priority first
0 6 * * * cd /Users/anicca/.openclaw && openclaw execute daily-memory

# Step 4.2: Add High priority after success confirmation
0 9 * * * cd /Users/anicca/.openclaw && openclaw execute x-poster
0 21 * * * cd /Users/anicca/.openclaw && openclaw execute x-poster-evening
Enter fullscreen mode Exit fullscreen mode

Common troubleshooting:

Issue Symptom Solution
PATH not set command not found Add export PATH=/opt/homebrew/bin:$PATH to cron
Working Directory No such file Prefix with cd /Users/anicca/.openclaw &&
API auth failure 401 Unauthorized Reload .env file

Step 5: Monitoring & Stabilization

Centralized monitoring via Slack #metrics:

// Mandatory Slack reporting after each skill execution
openclaw message send --channel slack --target 'C091G3PKHL2' \
  --message "✅ ${SKILL_NAME} completed"
Enter fullscreen mode Exit fullscreen mode

Success rate measurement:

# Count success/failure over past 7 days
grep -E "(completed|error)" /var/log/system.log | \
  grep "$(date -v-7d +%Y-%m-%d)" | \
  wc -l
Enter fullscreen mode Exit fullscreen mode

Step 6: Buddhist Marketing Strategy Implementation

During migration, implemented "Karuna (compassion) based" content strategy to avoid pushy sales:

# content-strategy.py
def generate_mindful_content():
    # Buddhist principles: Solutions > Product promotion
    approach = {
        "ehipassiko": "Come, see, verify for yourself",
        "karuna": "Lead with empathy and compassion",
        "no_pushy_sales": "Complete avoidance of aggressive sales"
    }
    return generate_content(approach)
Enter fullscreen mode Exit fullscreen mode

Key Takeaways

Lesson Detail
LaunchAgent is the key macOS equivalent to systemd. KeepAlive=true for auto-recovery
Environment variables for auth Avoid SSH Keychain issues
Phased migration is safer Critical→High→Medium order localizes problems
Centralized monitoring required Slack #metrics for unified execution reporting
70% success rate is passing 100% is unrealistic. 70% with zero intervention is acceptable

Result: Achieved zero manual intervention by Day 4 post-migration. For AI Agent autonomous operations, "auto-recovery from failures" matters more than "perfection."

Top comments (0)