VPS에서 Mac Mini로 AI 에이전트 운영을 마이그레이션하는 방법 (43개의 Cron 작업을 깨지 않고)

발행: (2026년 3월 1일 오전 02:12 GMT+9)
5 분 소요
원문: Dev.to

Source: Dev.to

개요

VPS에서 Mac Mini(macOS 14.6.0)로 OpenClaw AI 에이전트를 마이그레이션하면서 43개의 cron 작업을 모두 그대로 유지했습니다. 4일 차에 시스템은 수동 개입 없이 70 % 성공률을 달성했습니다. 주요 성공 요인은 자동 시작을 위한 LaunchAgent 설정과 API 인증 토큰의 마이그레이션이었습니다.

준비

  • 환경: VPS에서 실행되는 OpenClaw AI 에이전트 실행 플랫폼.
  • 대상: SSH 접근이 가능한 Mac Mini (macOS 14.6.0).
  • 자격 증명: GitHub, Anthropic 등의 API 토큰.
  • 참조: Site24x7 – Server Migration Best Practices – “모든 종속성을 매핑하여 마이그레이션 전략을 계획하세요”.

기존 크론 작업 매핑

# 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
PriorityJob TypeCountNotes
중요daily‑memory, article‑writer5일일 기록 시스템
높음x‑poster, trend‑hunter15콘텐츠 게시
보통autonomy‑check, app‑metrics23모니터링 및 메트릭

자동 시작을 위한 LaunchAgent

LaunchAgent plist를 생성합니다 (파일 경로: ~/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>

에이전트를 로드하고 시작합니다:

launchctl load ~/Library/LaunchAgents/com.openclaw.gateway.plist
launchctl start com.openclaw.gateway

Note: LaunchAgent는 macOS에서 systemd와 동일한 역할을 하며, KeepAlive=true는 자동 복구를 보장합니다.

Source: OpenClaw Issue #21508 – SSH Keychain access problems.

Claude 코드 인증 (SSH 세션)

# 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

API 키 설정

환경 변수를 ~/.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

단계적 마이그레이션 (빅뱅이 아님)

4.1 단계 – 중요 우선순위 먼저 마이그레이션

0 6 * * * cd /Users/anicca/.openclaw && openclaw execute daily-memory

4.2 단계 – 확인 후 고우선순위 추가

0 9 * * * cd /Users/anicca/.openclaw && openclaw execute x-poster
0 21 * * * cd /Users/anicca/.openclaw && openclaw execute x-poster-evening

모범 사례: 문제를 국지화하기 위해 중요 → 고 → 중 순으로 진행하십시오.

공통 문제 해결

문제증상해결책
PATH not setcommand not foundcron 환경에 export PATH=/opt/homebrew/bin:$PATH를 추가하세요.
Working Directory“파일을 찾을 수 없음”명령 앞에 cd /Users/anicca/.openclaw &&를 붙이세요.
API auth failure401 Unauthorized.env 파일을 다시 로드하거나 토큰 값을 확인하세요.

Slack을 통한 중앙 집중 모니터링

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

성공률 측정

# 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

“카루나(연민)‑기반” 콘텐츠 전략

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

주요 교훈

  • LaunchAgent는 macOS에서 자동 복구에 필수적입니다.
  • 인증 변수를 SSH 키체인에 저장하지 않아 접근 문제를 방지하세요.
  • 단계적 마이그레이션은 위험을 줄이며, Critical 작업을 먼저 처리합니다.
  • 중앙 집중식 모니터링(예: Slack)은 통합 실행 보고서를 제공합니다.
  • 자동 에이전트에 대해 70 % 성공률과 수동 개입 제로는 현실적이고 허용 가능한 목표입니다.

Result

Day 4 이후 마이그레이션에서는 수동 개입이 전혀 필요하지 않았습니다. AI‑agent 자율 운영에서는 “실패로부터의 자동 복구”가 100 % 완벽함을 달성하는 것보다 더 중요합니다.

0 조회
Back to Blog

관련 글

더 보기 »

일이 정신 건강 위험이 될 때

markdown !Ravi Mishrahttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fu...