Script-Only Cron Jobs: Automate Without Burning Tokens
Script-Only Cron Jobs — easy-to-understand guide based on official docs
Script-Only Cron Jobs: Automate Without Burning Tokens
In our last post, we covered the basics of setting up cron jobs with Hermes Agent. Today, we’re diving deeper into a powerful feature that can save you tokens and simplify your automation: script-only cron jobs.
The idea is simple: why pay for an LLM call when your script already knows exactly what to say? If you have a recurring task where the output is predictable — like a memory alert, disk space warning, or heartbeat check — you can skip the agent entirely.
Two Ways to Go Zero-Token
You have two options when you don’t need the LLM:
-
Recurring watchdog: If your script produces the exact message you want to send (think “Disk usage at 90%!”), use a script-only cron job. Same scheduler, zero tokens. You can even ask Hermes to set this up for you in chat — the
cronjobtool knows when to useno_agent=Trueand writes the script for you. -
One-shot from a running script: If you have a CI step, post-commit hook, or deploy script that’s already running, use
hermes sendto pipe stdout or a file straight to Telegram, Discord, or Slack. No cron entry needed.
The [SILENT] Trick
Before we jump into patterns, here’s a pro tip: for monitoring jobs, tell the agent to respond with just [SILENT] when nothing changed. Cron delivery treats this as the quiet marker — you only get notified when something actually happens. No more spam at 3 AM.
Pattern 1: Website Change Monitor
Watch a URL for changes and get notified only when something’s different. The secret weapon here is the script parameter — a Python script runs before each execution, and its stdout becomes context for the agent. The script handles the mechanical work (fetching, diffing); the agent handles the reasoning (is this change interesting?).
First, create the monitoring script:
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")
Now set up the cron job:
/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
Pattern 2: Weekly Report
Compile information from multiple sources into a formatted summary. This runs once a week and delivers to your home channel.
/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
From the 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
The 0 9 * * 1 is a standard cron expression: 9:00 AM every Monday.
Pattern 3: GitHub Repository Watcher
Monitor a repository for new issues, PRs, or releases.
/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
Important: Notice how the prompt includes the exact gh commands. Cron agents have no conversation history from previous runs — spell everything out. (Persistent memory does load, so durable preferences saved to MEMORY.md carry over, but don’t rely on it for job-critical details.)
Pattern 4: Data Collection Pipeline
Scrape data at regular intervals, save to files, and detect trends over time. This combines a script (for collection) with the agent (for analysis).
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 summary for the agent
print(f"Collected prices at {entry['timestamp']}")
print(f"Bitcoin: ${data['bitcoin']['usd']}, Ethereum: ${data['ethereum']['usd']}")
Key Takeaway
Cron jobs run in fresh agent sessions with no memory of your current chat. Your prompts must be completely self-contained — include everything the agent needs to know. And when you don’t need the LLM at all, script-only cron jobs are your zero-token friend.
For the full feature reference, check out the Scheduled Tasks (Cron) docs. Happy automating!
📖 Official Docs
This article is based on the official Hermes Agent documentation:Official docs › guides/automate-with-cron