AI Agent Cron Jobs
What are AI agent cron jobs?
AI agent cron jobs are scheduled tasks that trigger agent behavior at specific times. Like traditional cron jobs in computing, they execute on a schedule—but instead of running scripts, they invoke AI agents to perform tasks.
The insight: time creates events, events trigger agents.
0 9 * * 1 → Every Monday at 9 AM → Generate weekly report
0 18 * * * → Every day at 6 PM → Summarize today's emails
0 8 * * * → Every morning at 8 AM → Check calendar and brief user
Cron jobs enable agents to do things overnight, on weekends, and at precise moments—without humans initiating the interaction.
How agent cron jobs work
Traditional cron runs commands on a schedule:
0 9 * * * /path/to/script.sh
Agent cron invokes agents with specific tasks:
schedule: "0 9 * * 1" # Monday 9 AM
agent: "report-generator"
task: "Generate the weekly sales report and send to team@company.com"
The system:
- Monitors the schedule
- At the specified time, creates an agent session
- Delivers the task prompt to the agent
- Agent executes autonomously
- Results are delivered (email, file, notification)
Why agents need cron jobs
Autonomous execution
Humans shouldn't need to remember to ask for routine things:
- Daily briefings happen automatically
- Weekly reports generate on schedule
- Monthly reviews run without prompting
Optimal timing
Some tasks are best done at specific times:
- Market analysis before trading opens
- News digests before the workday starts
- System checks during off-hours
- Reminders at contextually appropriate moments
Separation from conversation
Cron jobs run independently from interactive sessions:
- No conversation history dependency
- Clean execution context
- Different model/configuration if needed
- Results delivered to specified channels
Reliability
Scheduled tasks are more reliable than hoping someone remembers:
- Compliance reports never missed
- Monitoring consistently executed
- Maintenance performed on schedule
Cron job patterns for agents
The daily briefing
name: "Morning Briefing"
schedule: "0 7 * * *" # 7 AM daily
agent: "assistant"
task: |
Prepare my morning briefing:
1. Today's calendar with travel time estimates
2. Top 5 urgent emails
3. Weather forecast
4. Any overnight news relevant to my work
Send to WhatsApp.
The periodic report
name: "Weekly Analytics"
schedule: "0 9 * * 1" # Monday 9 AM
agent: "analytics-agent"
task: |
Generate the weekly analytics report:
- Traffic and engagement metrics
- Conversion rates vs last week
- Notable trends or anomalies
Save to reports/week-{{week_number}}.md and send summary to Slack.
The maintenance task
name: "Memory Cleanup"
schedule: "0 3 * * 0" # Sunday 3 AM
agent: "maintenance"
task: |
Perform weekly memory maintenance:
- Archive daily logs older than 30 days
- Consolidate significant events into MEMORY.md
- Prune redundant or outdated information
- Report any issues found
The monitoring check
name: "System Health"
schedule: "*/30 * * * *" # Every 30 minutes
agent: "monitor"
task: |
Check system health:
- API response times
- Error rates
- Resource utilization
If any metric exceeds thresholds, alert immediately.
Otherwise, log results silently.
The reminder
name: "Project Deadline Reminder"
schedule: "0 10 15 3 *" # March 15 at 10 AM
agent: "assistant"
task: |
Remind user: The Project Phoenix deadline is in 2 weeks.
Review current status and suggest priorities.
Implementing agent cron jobs
Basic scheduling
from apscheduler.schedulers.background import BackgroundScheduler
from agent_framework import create_session
scheduler = BackgroundScheduler()
def run_agent_task(agent_id, task):
session = create_session(agent_id)
result = session.execute(task)
deliver_result(result)
# Add job
scheduler.add_job(
run_agent_task,
'cron',
hour=9,
day_of_week='mon',
args=['report-agent', 'Generate weekly report']
)
scheduler.start()
Configuration-based scheduling
# cron.yaml
jobs:
- name: morning-briefing
schedule: "0 7 * * *"
agent: assistant
task: "Generate morning briefing"
output:
channel: whatsapp
- name: weekly-report
schedule: "0 9 * * 1"
agent: analytics
task: "Generate weekly analytics report"
output:
file: "reports/weekly/{{date}}.md"
notification: slack
Command-line scheduling
# Create a one-time reminder
clawdbot cron add --at "2024-03-15 10:00" --task "Remind about project deadline"
# Create recurring task
clawdbot cron add --schedule "0 9 * * 1" --agent report-generator --task "Generate weekly sales report"
# List scheduled jobs
clawdbot cron list
# Remove a job
clawdbot cron remove job-id
Cron jobs vs heartbeats
Both create scheduled agent activity, but serve different purposes:
| Aspect | Cron Job | Heartbeat |
|---|---|---|
| Timing | Specific times (9 AM Monday) | Regular intervals (every 30 min) |
| Purpose | Execute specific tasks | Check for work, maintain awareness |
| Context | Isolated, clean session | Maintains conversation context |
| Output | Always produces result | May do nothing (HEARTBEAT_OK) |
| Scope | Single defined task | Multiple potential actions |
Use cron when:
- Exact timing matters
- Task is well-defined and specific
- You want isolated execution
- Output should go to specific destination
Use heartbeat when:
- Checking multiple things at once
- Timing can be approximate
- Need conversational context
- Agent decides what to do based on what it finds
Combined approach:
Heartbeat (every 30 min): Check for urgent items, stay aware
Cron (9 AM daily): Generate morning briefing
Cron (Monday 9 AM): Weekly report
Cron (1st of month): Monthly summary
Best practices for agent cron jobs
Clear task definitions
Be specific about what the agent should do:
# Good
task: |
Generate weekly sales report including:
- Revenue by region
- Top 10 products
- Week-over-week comparison
Save to reports/sales-{{date}}.md
# Bad
task: "Do the weekly report"
Specify output channels
Where should results go?
output:
primary: email
recipients: ["team@company.com"]
cc_file: "reports/archive/{{date}}.md"
on_error: notify_admin
Handle failures gracefully
Cron jobs can fail. Plan for it:
retry:
attempts: 3
delay: 5m
on_failure:
notify: admin@company.com
fallback: "Send error report instead of regular report"
Consider time zones
Be explicit about when jobs run:
schedule: "0 9 * * *"
timezone: "America/New_York" # Always specify
Avoid overlapping jobs
Ensure jobs don't step on each other:
# Stagger similar jobs
job1: "0 9 * * *" # 9:00 AM
job2: "30 9 * * *" # 9:30 AM
job3: "0 10 * * *" # 10:00 AM
Test before scheduling
Run the task manually first:
clawdbot run --agent analytics --task "Generate weekly report" --dry-run
Cron jobs in production
Production agent systems like Clawdbot/OpenClaw support cron with:
Schedule management:
clawdbot cron add --schedule "0 9 * * *" --task "Morning briefing"
clawdbot cron list
clawdbot cron enable/disable job-id
clawdbot cron remove job-id
Execution logging:
Job: morning-briefing
Started: 2024-01-15 09:00:00
Agent: assistant
Status: completed
Duration: 45s
Output: Delivered to WhatsApp
Error handling:
- Automatic retries
- Admin notifications
- Failure logs
- Recovery procedures
Model configuration:
jobs:
- name: simple-reminder
model: gpt-4o-mini # Cheap model for simple tasks
- name: complex-analysis
model: claude-opus # Powerful model for hard tasks
thinking: extended # Enable extended thinking
Common cron job mistakes
Too frequent scheduling
Running complex agents every minute wastes resources and money. Match frequency to actual need.
Missing error handling
"It works in testing" isn't enough. Production jobs fail. Plan for recovery.
Vague task definitions
Agents interpret vague instructions variably. Be specific about exactly what you want.
Ignoring output
If no one reads the output, why run the job? Ensure results reach the right people.
Time zone confusion
"9 AM" means different things in different places. Always specify timezone.
Need scheduled AI tasks? Chipp agents can run on schedules to deliver reports, check on processes, and handle routine work automatically.
Related Terms
Build AI agents with Chipp
Create custom AI agents with knowledge, actions, and integrations—no coding required.
Learn more