🤖HermesBlog
Hermes Feature Guides · جزء 178/9/2026

Level Up Your Cron Game: 5 Automation Patterns You Can Use Today

Cron Troubleshooting Guide — easy-to-understand guide based on official docs

guide-cron-troubleshooting

ارفع مستوى أتمتة مهامك: 5 أنماط أتمتة يمكنك استخدامها اليوم

إذن قمت بإعداد أول مهمة cron لك مع Hermes Agent وأنت منبهر بها. لكن هل تعلم أن هناك الكثير مما يمكنك فعله؟ درس البوت الموجز اليومي هو مجرد البداية. دعنا نستكشف خمسة أنماط أتمتة واقعية ستجعل حياتك أسهل.

القاعدة الذهبية: أوامر مكتفية ذاتيًا

قبل أن نتعمق، إليك أهم شيء يجب تذكره: مهام cron تعمل في جلسات وكيل جديدة تمامًا. وكيلك لا يمتلك أي ذاكرة من محادثتك الحالية. لذلك يجب أن يكون كل أمر مكتفيًا ذاتيًا تمامًا — قم بتضمين كل ما يحتاجه الوكيل لمعرفته، من السياق إلى الأوامر الدقيقة.

تخطَّ نموذج اللغة عندما لا تحتاجه

ليست كل أتمتة تحتاج إلى نموذج لغوي. لديك خياران بدون أي رموز (توكينات):

  • مراقب متكرر: إذا كان السكربت الخاص بك ينتج الرسالة المطلوبة بالفعل (مثل تنبيهات الذاكرة أو إشارات النبض)، استخدم مهام cron للسكربت فقط. فقط اطلب من Hermes في المحادثة — أداة cronjob تعرف متى تستخدم no_agent=True وتكتب السكربت نيابة عنك.
  • إرسال لمرة واحدة من سكربت قيد التشغيل: لخطوات CI أو خطافات النشر، استخدم hermes send لإرسال المخرجات مباشرة إلى Telegram أو Discord دون أي إعداد cron.

النمط 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:

/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] فقط، ويتعامل تسليم cron مع ذلك كعلامة هدوء. لن يتم إشعارك إلا عندما يحدث شيء فعليًا — لا رسائل مزعجة في ساعات الهدوء.


النمط 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 هو تعبير cron قياسي: الساعة 9:00 صباحًا كل يوم اثنين.


النمط 3: مراقب مستودعات GitHub

راقب أي مستودع لمعرفة القضايا الجديدة أو طلبات السحب أو الإصدارات:

/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 الدقيقة؟ هذا مقصود. وكيل cron لا يمتلك أي سجل محادثة — اشرح كل شيء بالتفصيل. (الذاكرة الدائمة تُحمَّل، لذا فإن التفضيلات الدائمة المحفوظة في 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']}")

ثم قم بإعداد مهمة cron تشغّل السكربت وتطلب من الوكيل تحليل البيانات المجمعة للبحث عن الاتجاهات.


النمط 5: المراقب بالسكربت فقط

للتنبيهات حيث ينتج السكربت الرسالة المطلوبة بالفعل، تخطَّ نموذج اللغة تمامًا:

/cron add "every 5m" --script ~/.hermes/scripts/check-disk.py --no-agent --deliver slack

أداة cronjob تختار تلقائيًا no_agent=True عندما يكون ذلك منطقيًا، وتكتب السكربت نيابة عنك.


جاهز للأتمتة؟

هذه الأنماط هي مجرد نقاط بداية. اخلط وطابق بينها — استخدم السكربتات للأعمال الميكانيكية، والوكلاء للاستنتاج والتحليل، و[SILENT] للحفاظ على إشعاراتك نظيفة. للمرجع الكامل للميزات، راجع وثائق المهام المجدولة (Cron). أتمتة سعيدة!


📖 التوثيق الرسمي

この記事は Hermes Agent のالتوثيق الرسميに基づいています:التوثيق الرسمي › guides/automate-with-cron