크론 게임 레벨 업: 오늘 바로 쓸 수 있는 5가지 자동화 패턴
Cron Troubleshooting Guide — easy-to-understand guide based on official docs
크론 게임 레벨 업: 오늘 바로 쓸 수 있는 5가지 자동화 패턴
Hermes Agent로 첫 크론 작업을 설정해 봤다면, 이제 그 매력에 빠졌을 겁니다. 하지만 알고 계셨나요? 훨씬 더 많은 것을 할 수 있다는 걸요. 데일리 브리핑 봇 튜토리얼은 그저 시작에 불과합니다. 삶을 편하게 만들어 줄 5가지 실전 자동화 패턴을 살펴보겠습니다.
가장 중요한 규칙: 자족적 프롬프트
본격적으로 들어가기 전에, 가장 중요한 것을 기억하세요: 크론 작업은 새로운 에이전트 세션에서 실행됩니다. 에이전트는 현재 채팅에 대한 기억이 전혀 없습니다. 따라서 모든 프롬프트는 완전히 자족적이어야 합니다 — 컨텍스트부터 정확한 명령어까지 에이전트가 알아야 할 모든 것을 포함해야 합니다.
필요 없을 때는 LLM 건너뛰기
모든 자동화에 언어 모델이 필요한 것은 아닙니다. 토큰을 사용하지 않는 두 가지 옵션이 있습니다:
- 반복 감시 작업: 스크립트가 이미 정확한 메시지를 생성하는 경우(예: 메모리 알림, 하트비트), 스크립트 전용 크론 작업을 사용하세요. 채팅에서 Hermes에게 요청하기만 하면 됩니다 —
cronjob도구가no_agent=True를 사용해야 할 때를 알고 스크립트를 작성해 줍니다. - 실행 중인 스크립트에서 1회 전송: CI 단계나 배포 훅의 경우,
hermes send를 사용하여 크론 설정 없이 출력을 Telegram이나 Discord로 바로 파이프하세요.
패턴 1: 웹사이트 변경 모니터
가격 페이지가 변경되거나 경쟁사가 사이트를 업데이트하는 시점을 알고 싶으신가요? 이 패턴은 Python 스크립트가 기계적인 작업을 수행하고, 에이전트가 추론을 담당합니다.
먼저 모니터링 스크립트를 만듭니다:
mkdir -p ~/.hermes/scripts
import hashlib, json, os, urllib.request
URL = "https://example.com/pricing"
STATE_FILE = os.path.expanduser("~/.hermes/scripts/.watch-site-state.json")
# Fetch current content
req = urllib.request.Request(URL, headers={"User-Agent": "Hermes-Monitor/1.0"})
content = urllib.request.urlopen(req, timeout=30).read().decode()
current_hash = hashlib.sha256(content.encode()).hexdigest()
# Load previous state
prev_hash = None
if os.path.exists(STATE_FILE):
with open(STATE_FILE) as f:
prev_hash = json.load(f).get("hash")
# Save current state
with open(STATE_FILE, "w") as f:
json.dump({"hash": current_hash, "url": URL}, f)
# Output for the agent
if prev_hash and prev_hash != current_hash:
print(f"CHANGE DETECTED on {URL}")
print(f"Previous hash: {prev_hash}")
print(f"Current hash: {current_hash}")
print(f"\nCurrent content (first 2000 chars):\n{content[:2000]}")
else:
print("NO_CHANGE")
이제 크론 작업을 설정합니다:
/cron add "every 1h" "If the script output says CHANGE DETECTED, summarize what changed on the page and why it might matter. If it says NO_CHANGE, respond with just [SILENT]." --script ~/.hermes/scripts/watch-site.py --name "Pricing monitor" --deliver telegram
프로 팁: [SILENT] 트릭은 정말 유용합니다. 변경 사항이 없을 때 에이전트가 [SILENT]라고만 응답하면, 크론 전달이 이를 조용한 표시로 처리합니다. 실제로 무언가 발생했을 때만 알림을 받게 되므로 — 조용한 시간대에 스팸이 오지 않습니다.
패턴 2: 주간 보고서
여러 소스의 정보를 종합하여 형식화된 요약으로 만듭니다. 매주 월요일 오전 9시에 실행됩니다:
/cron add "0 9 * * 1" "Generate a weekly report covering:
1. Search the web for the top 5 AI news stories from the past week
2. Search GitHub for trending repositories in the 'machine-learning' topic
3. Check Hacker News for the most discussed AI/ML posts
Format as a clean summary with sections for each source. Include links.
Keep it under 500 words — highlight only what matters." --name "Weekly AI digest" --deliver telegram
CLI에서는 다음과 같이 보입니다:
hermes cron create "0 9 * * 1" \
"Generate a weekly report covering the top AI news, trending ML GitHub repos, and most-discussed HN posts. Format with sections, include links, keep under 500 words." \
--name "Weekly AI digest" \
--deliver telegram
0 9 * * 1은 표준 크론 표현식입니다: 매주 월요일 오전 9시.
패턴 3: GitHub 저장소 감시자
새로운 이슈, PR 또는 릴리스를 위해 저장소를 주시합니다:
/cron add "every 6h" "Check the GitHub repository NousResearch/hermes-agent for:
- New issues opened in the last 6 hours
- New PRs opened or merged in the last 6 hours
- Any new releases
Use the terminal to run gh commands:
gh issue list --repo NousResearch/hermes-agent --state open --json number,title,author,createdAt --limit 10
gh pr list --repo NousResearch/hermes-agent --state all --json number,title,author,createdAt,mergedAt --limit 10
Filter to only items from the last 6 hours. If nothing new, respond with [SILENT].
Otherwise, provide a concise summary of the activity." --name "Repo watcher" --deliver discord
경고: 프롬프트에 정확한 gh 명령어가 포함되어 있다는 점을 눈치채셨나요? 의도적인 것입니다. 크론 에이전트는 대화 기록이 없으므로 모든 것을 명시해야 합니다. (영구 메모리는 로드되므로 MEMORY.md에 저장된 지속적인 선호 사항은 전달되지만, 작업에 중요한 세부 사항은 이에 의존하지 마세요.)
패턴 4: 데이터 수집 파이프라인
정기적인 간격으로 데이터를 스크래핑하고, 파일에 저장하며, 시간에 따른 추세를 감지합니다. 수집을 위한 스크립트와 분석을 위한 에이전트를 결합합니다:
import json, os, urllib.request
from datetime import datetime
DATA_DIR = os.path.expanduser("~/.hermes/data/prices")
os.makedirs(DATA_DIR, exist_ok=True)
# Fetch current data (example: crypto prices)
url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd"
data = json.loads(urllib.request.urlopen(url, timeout=30).read())
# Append to history file
entry = {"timestamp": datetime.now().isoformat(), "prices": data}
history_file = os.path.join(DATA_DIR, "history.jsonl")
with open(history_file, "a") as f:
f.write(json.dumps(entry) + "\n")
print(f"Collected prices at {entry['timestamp']}: BTC ${data['bitcoin']['usd']}, ETH ${data['ethereum']['usd']}")
그런 다음 스크립트를 실행하고 수집된 데이터의 추세를 분석하도록 에이전트에 요청하는 크론 작업을 설정합니다.
패턴 5: 스크립트 전용 감시 작업
스크립트가 이미 정확한 메시지를 생성하는 알림의 경우, LLM을 완전히 건너뜁니다:
/cron add "every 5m" --script ~/.hermes/scripts/check-disk.py --no-agent --deliver slack
cronjob 도구는 필요할 때 자동으로 no_agent=True를 선택하고, 스크립트를 직접 작성해 줍니다.
자동화할 준비가 되셨나요?
이 패턴들은 시작점에 불과합니다. 서로 조합해 보세요 — 기계적인 작업에는 스크립트를, 추론에는 에이전트를, 알림을 깔끔하게 유지하려면 [SILENT]를 사용하세요. 전체 기능 참조는 예약 작업 (크론) 문서를 확인하세요. 자동화를 즐기세요!
📖 공식 문서
この記事は Hermes Agent の공식 문서に基づいています:공식 문서 › guides/automate-with-cron