Automate with Cron
This guide covers practical cron automation patterns for common use cases.
Pattern 1: Website monitoring
Check if a website is up and alert if down:
monoclaw cron create "*/5 * * * *" \
"Check if https://example.com returns HTTP 200. If not, describe the error code and response time. If yes, respond with [SILENT]." \
--name "Uptime monitor" \
--deliver telegram
Pattern 2: Pricing monitor
Track competitor pricing changes:
cat > ~/.monoclaw/scripts/check-pricing.py << 'EOF'
import requests, json, os
# Fetch current pricing
response = requests.get("https://competitor.com/api/pricing")
data = response.json()
# Compare with last known price
last_file = os.path.expanduser("~/.monoclaw/data/last-pricing.json")
if os.path.exists(last_file):
with open(last_file) as f:
last = json.load(f)
if data != last:
print("PRICE_CHANGE")
print(json.dumps({"old": last, "new": data}))
else:
print("NO_CHANGE")
else:
print("FIRST_RUN")
with open(last_file, "w") as f:
json.dump(data, f)
EOF
monoclaw cron create "0 * * * *" \
"Analyze the pricing data. If NO_CHANGE or FIRST_RUN, respond with [SILENT]. If PRICE_CHANGE, summarize what changed and by how much." \
--script ~/.monoclaw/scripts/check-pricing.py \
--name "Pricing monitor" \
--deliver slack
Pattern 3: Daily report generation
Generate and email a daily metrics report:
monoclaw cron create "0 8 * * *" \
"Generate a daily metrics report:
1. Check server disk usage
2. Check database size
3. List any error logs from the last 24 hours
4. Summarize GitHub activity (commits, PRs, issues)
Format as a professional report with sections." \
--skills "system-admin,github" \
--name "Daily report" \
--deliver email
Pattern 4: Content curation
Curate and deliver industry news:
monoclaw cron create "0 9 * * 1" \
"Weekly AI digest:
1. Search for 5 major AI announcements from last week
2. Find 3 trending repos on GitHub
3. List 2 notable arXiv papers
4. Write a brief analysis of the most important trend
Deliver as a formatted newsletter." \
--skills "web-search,arxiv" \
--name "Weekly AI Digest" \
--deliver telegram
Pattern 5: Automated PR review
Review new pull requests:
monoclaw webhook subscribe pr-review \
--events "pull_request" \
--prompt "Review PR #{pull_request.number}: {pull_request.title} by {pull_request.user.login}.
Check for:
- Security issues
- Code quality
- Test coverage
- Documentation updates
Provide constructive feedback." \
--skills "github-code-review" \
--deliver github_comment
Pattern 6: Data pipeline
Process incoming data files:
cat > ~/.monoclaw/scripts/process-incoming.py << 'EOF'
import os, glob
incoming_dir = os.path.expanduser("~/incoming/")
files = glob.glob(incoming_dir + "*.csv")
if not files:
print("NO_FILES")
else:
print(f"FILES_FOUND: {len(files)}")
for f in files:
print(f)
EOF
monoclaw cron create "*/15 * * * *" \
"If NO_FILES, respond with [SILENT]. If FILES_FOUND, process each CSV: validate headers, check for anomalies, and generate a summary. Move processed files to ~/processed/." \
--script ~/.monoclaw/scripts/process-incoming.py \
--name "Data pipeline" \
--deliver local
Multi-step workflows
Chain multiple cron jobs together:
# Step 1: Collect data at 2 AM
monoclaw cron create "0 2 * * *" \
"Collect yesterday's sales data and save to ~/reports/sales-raw.json" \
--name "Collect sales data"
# Step 2: Analyze at 3 AM
monoclaw cron create "0 3 * * *" \
"Analyze ~/reports/sales-raw.json. Generate insights and trends." \
--name "Analyze sales"
# Step 3: Deliver at 8 AM
monoclaw cron create "0 8 * * *" \
"Read ~/reports/sales-analysis.md and send as an email summary." \
--name "Deliver sales report" \
--deliver email
Best practices
- Use [SILENT] — Prevents notification fatigue
- Test with --dry-run — Verify before scheduling
- Set reasonable intervals — Don't overwhelm APIs or your inbox
- Log everything — Check
monoclaw cron logsregularly - Handle failures — Set up alerts for failed jobs
- Clean up old jobs — Remove obsolete cron jobs