How to Migrate AI Agent Operations from VPS to Mac Mini (Without Breaking 43 Cron Jobs)
Source: Dev.to
Overview
Migrated the OpenClaw AI Agent from a VPS to a Mac Mini (macOS 14.6.0) while keeping all 43 cron jobs intact. By Day 4 the system achieved a 70 % success rate with zero manual intervention. The critical success factors were the LaunchAgent configuration for auto‑startup and the migration of API authentication tokens.
Preparation
- Environment: OpenClaw AI Agent execution platform on a VPS.
- Target: Mac Mini (macOS 14.6.0) with SSH access.
- Credentials: API tokens for GitHub, Anthropic, etc.
- Reference: Site24x7 – Server Migration Best Practices – “Plan your migration strategy by mapping all dependencies”.
Mapping Existing Cron Jobs
# Extract current cron schedule
crontab -l > current-crons.txt
# Analyse 43 jobs by priority
grep -E "article-writer|trend-hunter|x-poster" current-crons.txt
| 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 |
LaunchAgent for Auto‑Startup
Create the LaunchAgent plist (saved as ~/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/anicda/.openclaw</string>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Load and start the agent:
launchctl load ~/Library/LaunchAgents/com.openclaw.gateway.plist
launchctl start com.openclaw.gateway
Note: LaunchAgent is the macOS equivalent of
systemd;KeepAlive=trueensures automatic recovery.
Claude Code Authentication (SSH Sessions)
# Set the OAuth token for Claude Code
export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-xxx...
echo 'export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-xxx...' >> ~/.zshrc
Source: OpenClaw Issue #21508 – SSH Keychain access problems.
API Keys Setup
Store environment variables in ~/.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
Phased Migration (Not a 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 Confirmation
0 9 * * * cd /Users/anicca/.openclaw && openclaw execute x-poster
0 21 * * * cd /Users/anicca/.openclaw && openclaw execute x-poster-evening
Best practice: Move from Critical → High → Medium to localize any issues.
Common Troubleshooting
| Issue | Symptom | Solution |
|---|---|---|
PATH not set | command not found | Add export PATH=/opt/homebrew/bin:$PATH to the cron environment. |
| Working Directory | “No such file” | Prefix commands with cd /Users/anicca/.openclaw &&. |
| API auth failure | 401 Unauthorized | Reload the .env file or verify token values. |
Centralized Monitoring via Slack
# Mandatory Slack reporting after each skill execution
openclaw message send --channel slack --target 'C091G3PKHL2' \
--message "✅ ${SKILL_NAME} completed"
Success‑Rate Measurement
# Count success/failure over the past 7 days
grep -E "(completed|error)" /var/log/system.log |
grep "$(date -v-7d +%Y-%m-%d)" |
wc -l
“Karuna (Compassion)‑Based” Content Strategy
# 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)
Key Lessons
- LaunchAgent is essential for auto‑recovery on macOS.
- Keep authentication variables out of the SSH keychain to avoid access problems.
- A phased migration reduces risk; handle Critical jobs first.
- Centralized monitoring (e.g., Slack) provides unified execution reporting.
- A 70 % success rate with zero manual intervention is a realistic and acceptable target for autonomous agents.
Result
Zero manual intervention was required by Day 4 post‑migration. For AI‑agent autonomous operations, “auto‑recovery from failures” matters more than achieving 100 % perfection.