본문으로 건너뛰기

Cron으로 모든 것을 자동화하세요

일일 브리핑 봇 튜토리얼에서는 기본 사항을 다룹니다. 이 가이드에서는 더 나아가 자신의 워크플로에 맞게 조정할 수 있는 5가지 실제 자동화 패턴을 설명합니다.

전체 기능 참조는 예약된 작업(Cron)을 참조하세요.

Key Concept

Cron 작업은 현재 채팅에 대한 기억 없이 새로운 에이전트 세션에서 실행됩니다. 프롬프트는 완전히 독립적이어야 하며 상담사가 알아야 할 모든 것을 포함해야 합니다.

Don't need the LLM? Use no-agent mode.

스크립트가 보내려는 정확한 메시지(메모리 경고, 디스크 경고, CI 핑, 하트비트)를 이미 생성하는 반복 감시의 경우 스크립트 전용 크론 작업을 사용하여 LLM을 완전히 건너뜁니다. 제로 토큰, 동일한 스케줄러. 채팅에서 Hermes에게 하나를 설정해 달라고 요청할 수 있습니다. cronjob 도구는 언제 no_agent=True을 선택해야 하는지 알고 스크립트를 작성합니다.


패턴 1: 웹사이트 변경 모니터

변경 사항에 대한 URL을 확인하고 변경 사항이 있을 때만 알림을 받으세요.

script 매개변수는 여기서 비밀 무기입니다. Python 스크립트는 각 실행 전에 실행되며 해당 stdout은 에이전트의 컨텍스트가 됩니다. 스크립트는 기계적 작업(가져오기, 비교)을 처리합니다. 에이전트가 추론을 처리합니다(이 변경 사항이 흥미롭나요?).

모니터링 스크립트를 만듭니다.

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
The [SILENT] Trick

에이전트의 최종 응답에 [SILENT]이 포함되면 전달이 억제됩니다. 즉, 실제로 어떤 일이 발생했을 때만 알림을 받을 수 있으며 조용한 시간에는 스팸이 전송되지 않습니다.


패턴 2: 주간 보고서

여러 소스의 정보를 형식화된 요약으로 컴파일합니다. 일주일에 한 번 실행되며 홈 채널로 전송됩니다.

/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`은 표준 cron 표현식입니다: 매주 월요일 오전 9시.

---

## 패턴 3: GitHub 저장소 감시자 \{#pattern-2-weekly-report}

새로운 이슈, PR 또는 릴리스에 대한 저장소를 모니터링합니다.

```bash
/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
Self-Contained Prompts

프롬프트에 정확한 gh 명령이 어떻게 포함되어 있는지 확인하세요. 크론 에이전트는 이전 실행이나 기본 설정을 기억하지 않습니다. 모든 내용을 설명합니다.


패턴 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")

# Load recent history for analysis
lines = open(history_file).readlines()
recent = [json.loads(l) for l in lines[-24:]] # Last 24 data points

# Output for the agent
print(f"Current: BTC=${data['bitcoin']['usd']}, ETH=${data['ethereum']['usd']}")
print(f"Data points collected: {len(lines)} total, showing last {len(recent)}")
print(f"\nRecent history:")
for r in recent[-6:]:
print(f" {r['timestamp']}: BTC=${r['prices']['bitcoin']['usd']}, ETH=${r['prices']['ethereum']['usd']}")
````bash
/cron add "every 1h" "Analyze the price data from the script output. Report:
1. Current prices
2. Trend direction over the last 6 data points (up/down/flat)
3. Any notable movements (>5% change)

If prices are flat and nothing notable, respond with [SILENT].
If there's a significant move, explain what happened." \
--script ~/.hermes/scripts/collect-prices.py \
--name "Price tracker" \
--deliver telegram

스크립트는 기계적 수집을 수행합니다. 에이전트는 추론 레이어를 추가합니다.


패턴 5: 다중 기술 작업 흐름

복잡한 예약 작업을 위해 스킬을 함께 연결하세요. 프롬프트가 실행되기 전에 스킬이 순서대로 로드됩니다.

# Use the arxiv skill to find papers, then the obsidian skill to save notes
/cron add "0 8 * * *" "Search arXiv for the 3 most interesting papers on 'language model reasoning' from the past day. For each paper, create an Obsidian note with the title, authors, abstract summary, and key contribution." \
--skill arxiv \
--skill obsidian \
--name "Paper digest"

도구에서 직접:

cronjob(
action="create",
skills=["arxiv", "obsidian"],
prompt="Search arXiv for papers on 'language model reasoning' from the past day. Save the top 3 as Obsidian notes.",
schedule="0 8 * * *",
name="Paper digest",
deliver="local"
)

스킬은 순서대로 로드됩니다. 먼저 arxiv(에이전트에게 문서 검색 방법을 가르칩니다), 그 다음 obsidian(메모 작성 방법을 가르칩니다). 프롬프트는 그것들을 하나로 묶습니다.


작업 관리

# List all active jobs
/cron list

# Trigger a job immediately (for testing)
/cron run <job_id>

# Pause a job without deleting it
/cron pause <job_id>

# Edit a running job's schedule or prompt
/cron edit <job_id> --schedule "every 4h"
/cron edit <job_id> --prompt "Updated task description"

# Add or remove skills from an existing job
/cron edit <job_id> --skill arxiv --skill obsidian
/cron edit <job_id> --clear-skills

# Remove a job permanently
/cron remove <job_id>

납품대상

--deliver 플래그는 결과의 위치를 제어합니다.

대상사용 사례
origin--deliver origin작업을 생성한 동일한 채팅(기본값)
local--deliver local로컬 파일에만 저장
telegram--deliver telegram사용자의 텔레그램 홈 채널
discord--deliver discordDiscord 홈 채널
slack--deliver slackSlack 홈 채널
특정 채팅--deliver telegram:-1001234567890특정 텔레그램 그룹
스레드--deliver telegram:-1001234567890:17585특정 텔레그램 주제 스레드

자립형 프롬프트를 만드세요. 크론 작업의 에이전트는 대화 내용을 기억하지 않습니다. URL, 저장소 이름, 형식 기본 설정, 전달 지침을 프롬프트에 직접 포함하세요.

[SILENT]을 자유롭게 사용하세요. 작업 모니터링의 경우 항상 "변경된 사항이 없으면 [SILENT]로 응답하세요."와 같은 지침을 포함하세요. 이렇게 하면 알림 소음이 방지됩니다.

데이터 수집을 위해 스크립트를 사용하세요. script 매개변수를 사용하면 Python 스크립트가 지루한 부분(HTTP 요청, 파일 I/O, 상태 추적)을 처리할 수 있습니다. 에이전트는 스크립트의 stdout만 보고 이에 대한 추론을 적용합니다. 이는 에이전트가 직접 가져오는 것보다 저렴하고 안정적입니다.

/cron run으로 테스트하세요. 일정이 트리거될 때까지 기다리기 전에 /cron run <job_id>을 사용하여 즉시 실행하고 출력이 올바른지 확인하세요.

일정 표현식. 지원되는 형식: 상대 지연(30m), 간격(every 2h), 표준 크론 표현식(0 9 * * *) 및 ISO 타임스탬프(2025-06-15T09:00:00). daily at 9am과 같은 자연어는 지원되지 않습니다. 대신 0 9 * * *을 사용하세요.


전체 크론 참조(모든 매개변수, 특수 사례 및 내부)는 예약된 작업(Cron)을 참조하세요.