Cron Jobs: Automate Everything While You Sleep
Overview
Cron jobs are the most powerful feature in OpenClaw, transforming your agent from a reactive chatbot into a proactive autonomous system. This guide covers everything from basic scheduling to advanced multi-step workflows that run automatically while you sleep.
Why Cron Jobs Are Essential
The Transformation
Without cron jobs:
- Manual task execution
- Agent waits for your commands
- No different than using ChatGPT on your phone
With cron jobs:
- Autonomous operation 24/7
- Scheduled workflows execute automatically
- Agent becomes a true AI employee
Real-World Impact
Example workflow:
6:00 AM - Collect Twitter intelligence from monitored accounts
7:00 AM - Generate daily briefing with analysis and trends
7:30 AM - Create presentation with findings
8:00 AM - Deliver to Discord/Slack
6:00 AM - Collect Twitter intelligence from monitored accounts
7:00 AM - Generate daily briefing with analysis and trends
7:30 AM - Create presentation with findings
8:00 AM - Deliver to Discord/Slack
Result: Wake up to a complete, researched briefing every morning
How Cron Jobs Work
Cron Syntax
Format: minute hour day month weekday
Examples:
0 7 * * * → Every day at 7:00 AM
*/30 * * * * → Every 30 minutes
0 9 * * 1-5 → Weekdays at 9:00 AM
0 0 1 * * → First day of every month at midnight
0 */6 * * * → Every 6 hours
0 7 * * * → Every day at 7:00 AM
*/30 * * * * → Every 30 minutes
0 9 * * 1-5 → Weekdays at 9:00 AM
0 0 1 * * → First day of every month at midnight
0 */6 * * * → Every 6 hours
Field Breakdown
| Field | Values | Special Characters |
|---|---|---|
| Minute | 0-59 | * (any), */n (every n), n-m (range) |
| Hour | 0-23 | * (any), */n (every n), n-m (range) |
| Day | 1-31 | * (any), */n (every n), n-m (range) |
| Month | 1-12 | * (any), */n (every n), n-m (range) |
| Weekday | 0-7 (0=Sun) | * (any), n-m (range), 1-5 (weekdays) |
Common Patterns
Hourly:
0 * * * * → Top of every hour
*/15 * * * * → Every 15 minutes
0 * * * * → Top of every hour
*/15 * * * * → Every 15 minutes
Daily:
0 9 * * * → 9:00 AM every day
30 14 * * * → 2:30 PM every day
0 9 * * * → 9:00 AM every day
30 14 * * * → 2:30 PM every day
Weekly:
0 9 * * 1 → Monday at 9:00 AM
0 17 * * 5 → Friday at 5:00 PM
0 9 * * 1 → Monday at 9:00 AM
0 17 * * 5 → Friday at 5:00 PM
Monthly:
0 0 1 * * → First day of month at midnight
0 9 15 * * → 15th of every month at 9:00 AM
0 0 1 * * → First day of month at midnight
0 9 15 * * → 15th of every month at 9:00 AM
Creating Cron Jobs
Basic Creation
Method 1: Direct instruction
Create a cron job that runs every day at 7 AM to
generate my daily briefing
Create a cron job that runs every day at 7 AM to
generate my daily briefing
Method 2: Explicit syntax
Set up cron job: 0 7 * * *
Task: Execute skill daily_briefing
Set up cron job: 0 7 * * *
Task: Execute skill daily_briefing
Method 3: Natural language
Every morning at 6 AM, collect Twitter intelligence
from my monitored accounts and save to memory
Every morning at 6 AM, collect Twitter intelligence
from my monitored accounts and save to memory
Viewing Cron Jobs
List all jobs:
Show me my cron jobs
Show me my cron jobs
Expected output:
Active Cron Jobs:
1. Twitter Intelligence - 0 6 * * * (Every day at 6:00 AM)
2. Daily Briefing - 0 7 * * * (Every day at 7:00 AM)
3. Weekly Report - 0 9 * * 1 (Every Monday at 9:00 AM)
Active Cron Jobs:
1. Twitter Intelligence - 0 6 * * * (Every day at 6:00 AM)
2. Daily Briefing - 0 7 * * * (Every day at 7:00 AM)
3. Weekly Report - 0 9 * * 1 (Every Monday at 9:00 AM)
Modifying Cron Jobs
Update schedule:
Change the daily briefing cron job to run at 8 AM instead
Change the daily briefing cron job to run at 8 AM instead
Update task:
Update the Twitter intelligence job to also monitor
@newaccount in addition to existing accounts
Update the Twitter intelligence job to also monitor
@newaccount in addition to existing accounts
Disable temporarily:
Pause the weekly report cron job until next month
Pause the weekly report cron job until next month
Delete:
Remove the daily briefing cron job
Remove the daily briefing cron job
Advanced Cron Job Patterns
Multi-Step Workflows
Example: Research → Analysis → Presentation
# Daily Briefing Cron Job
Schedule: 0 7 * * *
## Step 1: Data Collection (6:00 AM)
Prerequisite cron: 0 6 * * *
- Execute skill: twitter_intelligence
- Execute skill: web_news_scraping
- Save results to memory/daily/
## Step 2: Analysis (7:00 AM)
This cron job
- Read collected data from memory
- Execute skill: identify_trends
- Execute skill: gap_analysis
## Step 3: Presentation (7:00 AM)
Same cron job, sequential
- Execute skill: create_briefing_presentation
- Include: trends, gaps, actionable insights
- Format: Web-accessible HTML
## Step 4: Delivery (7:00 AM)
Same cron job, final step
- Execute skill: send_to_discord
- Include: Presentation link, summary
# Daily Briefing Cron Job
Schedule: 0 7 * * *
## Step 1: Data Collection (6:00 AM)
Prerequisite cron: 0 6 * * *
- Execute skill: twitter_intelligence
- Execute skill: web_news_scraping
- Save results to memory/daily/
## Step 2: Analysis (7:00 AM)
This cron job
- Read collected data from memory
- Execute skill: identify_trends
- Execute skill: gap_analysis
## Step 3: Presentation (7:00 AM)
Same cron job, sequential
- Execute skill: create_briefing_presentation
- Include: trends, gaps, actionable insights
- Format: Web-accessible HTML
## Step 4: Delivery (7:00 AM)
Same cron job, final step
- Execute skill: send_to_discord
- Include: Presentation link, summary
Chained Cron Jobs
Pattern: Job A → Job B → Job C
Job A: 0 6 * * * - Collect data
Job B: 0 7 * * * - Analyze data (depends on Job A)
Job C: 0 8 * * * - Generate report (depends on Job B)
Job A: 0 6 * * * - Collect data
Job B: 0 7 * * * - Analyze data (depends on Job A)
Job C: 0 8 * * * - Generate report (depends on Job B)
Why chain instead of one job:
- Isolate failures (if Job A fails, Jobs B & C don't run)
- Easier debugging
- Can run Job B/C manually if needed
Parallel Execution
Pattern: Multiple jobs at same time
Job 1: 0 6 * * * - Twitter intelligence
Job 2: 0 6 * * * - Web scraping
Job 3: 0 6 * * * - Documentation updates
Job 4: 0 7 * * * - Synthesize all results
Job 1: 0 6 * * * - Twitter intelligence
Job 2: 0 6 * * * - Web scraping
Job 3: 0 6 * * * - Documentation updates
Job 4: 0 7 * * * - Synthesize all results
Benefits:
- Faster execution (parallel)
- Independent failure domains
- Easier to maintain
Note: Latest OpenClaw version handles parallel cron jobs correctly (older versions had conflicts)
Skills + Cron Jobs
The Power Combination
Cron jobs trigger skills for consistent, reliable execution
Example skill:
---
name: daily_briefing
description: Generates comprehensive daily briefing with research and analysis
---
# Daily Briefing Skill
## Data Sources
1. Twitter intelligence from memory/twitter/
2. Web news from memory/news/
3. Documentation updates from memory/docs/
## Analysis
- Identify top 5 trends
- Find gaps nobody is talking about
- Extract actionable insights
## Output Format
- HTML presentation
- Executive summary (3-5 bullets)
- Detailed findings (5-7 slides)
- Source links for all claims
## Delivery
- Post to Discord #daily-briefing channel
- Include direct link to presentation
- Mention @team if critical findings
---
name: daily_briefing
description: Generates comprehensive daily briefing with research and analysis
---
# Daily Briefing Skill
## Data Sources
1. Twitter intelligence from memory/twitter/
2. Web news from memory/news/
3. Documentation updates from memory/docs/
## Analysis
- Identify top 5 trends
- Find gaps nobody is talking about
- Extract actionable insights
## Output Format
- HTML presentation
- Executive summary (3-5 bullets)
- Detailed findings (5-7 slides)
- Source links for all claims
## Delivery
- Post to Discord #daily-briefing channel
- Include direct link to presentation
- Mention @team if critical findings
Cron job:
0 7 * * * Execute skill: daily_briefing
0 7 * * * Execute skill: daily_briefing
Result: Consistent, high-quality briefings every morning
Skill-Based Automation Benefits
Consistency:
- Same process every time
- No variation in quality
- Predictable output format
Maintainability:
- Update skill, not cron job
- Test skill independently
- Version control for skills
Reusability:
- Run skill manually when needed
- Use skill in other workflows
- Share skills across agents
Testing Cron Jobs
Critical: Test Before Scheduling
Problem:
Schedule cron for 3 AM → Go to sleep → Wake up → Nothing happened
Schedule cron for 3 AM → Go to sleep → Wake up → Nothing happened
Solution: Test immediately
Step 1: Create test cron
Create a cron job that runs in 2 minutes to test my
daily briefing workflow
Create a cron job that runs in 2 minutes to test my
daily briefing workflow
Step 2: Monitor execution
Watch for cron job completion notification
Watch for cron job completion notification
Step 3: Verify output
Check if briefing was generated correctly
Review Discord/Slack for delivery
Confirm all data sources were accessed
Check if briefing was generated correctly
Review Discord/Slack for delivery
Confirm all data sources were accessed
Step 4: Fix issues
If failed: Debug and fix
If successful: Schedule for production time
If failed: Debug and fix
If successful: Schedule for production time
Common Test Failures
Failure 1: Missing API keys
Error: OpenAI API key not found
Solution: Verify API keys in all config files
Error: OpenAI API key not found
Solution: Verify API keys in all config files
Failure 2: Skill not found
Error: Skill 'daily_briefing' does not exist
Solution: Check skill file location and name
Error: Skill 'daily_briefing' does not exist
Solution: Check skill file location and name
Failure 3: Permission denied
Error: Cannot write to memory/daily/
Solution: Check file permissions
Error: Cannot write to memory/daily/
Solution: Check file permissions
Failure 4: Timeout
Error: Job exceeded 30 minute timeout
Solution: Optimize workflow or increase timeout
Error: Job exceeded 30 minute timeout
Solution: Optimize workflow or increase timeout
Configuration Issues
Time Zone Problems
Symptom: Cron runs at wrong time
Cause: Server time zone ≠ Your time zone
Diagnosis:
# Check server time zone
date
timedatectl
# Check OpenClaw time zone
echo $TZ
# Check server time zone
date
timedatectl
# Check OpenClaw time zone
echo $TZ
Solution:
# Set time zone
export TZ="America/New_York"
# Or in OpenClaw config
{
"timezone": "America/New_York"
}
# Set time zone
export TZ="America/New_York"
# Or in OpenClaw config
{
"timezone": "America/New_York"
}
Verify:
What time zone are you using for cron jobs?
What time zone are you using for cron jobs?
API Key Configuration
Problem: Cron jobs run in different environment than interactive sessions
Symptom: Works manually, fails in cron
Cause: API keys not available to cron environment
Solution for MiniMax:
Check all config locations:
# 1. Main config
~/.openclaw/config.json
# 2. Provider config
~/.openclaw/providers/minimax.json
# 3. Auth profiles
~/.openclaw/auth/profiles.json
# 4. Environment variables
~/.openclaw/.env
# 1. Main config
~/.openclaw/config.json
# 2. Provider config
~/.openclaw/providers/minimax.json
# 3. Auth profiles
~/.openclaw/auth/profiles.json
# 4. Environment variables
~/.openclaw/.env
Ensure API key in ALL locations:
{
"providers": {
"minimax": {
"api_key": "your-key-here"
}
}
}
{
"providers": {
"minimax": {
"api_key": "your-key-here"
}
}
}
Verify:
Test my MiniMax API key configuration for cron jobs
Test my MiniMax API key configuration for cron jobs
Blocking Cron Jobs (Fixed in Latest Version)
Old problem: Multiple cron jobs would cancel each other
Symptom:
Job 1 starts at 6:00 AM
Job 2 starts at 6:05 AM
Job 1 gets cancelled
Job 1 starts at 6:00 AM
Job 2 starts at 6:05 AM
Job 1 gets cancelled
Solution: Update to latest OpenClaw version
Verify fix:
What version of OpenClaw am I running?
What version of OpenClaw am I running?
If old version:
# Update OpenClaw
npm update -g openclaw
# or
pip install --upgrade openclaw
# Update OpenClaw
npm update -g openclaw
# or
pip install --upgrade openclaw
Notification and Reporting
Discord Integration
Setup:
Configure Discord webhook for cron job notifications
Webhook URL: https://discord.com/api/webhooks/...
Configure Discord webhook for cron job notifications
Webhook URL: https://discord.com/api/webhooks/...
Notification types:
- Job started
- Job completed
- Job failed
- Job output summary
- Job started
- Job completed
- Job failed
- Job output summary
Example notification:
🤖 Daily Briefing Complete
✅ Twitter intelligence: 47 tweets collected
✅ Web scraping: 23 articles analyzed
✅ Trends identified: 5 key themes
✅ Presentation generated: https://...
📊 Top Trend: GPT-5 announcement generating significant discussion
🤖 Daily Briefing Complete
✅ Twitter intelligence: 47 tweets collected
✅ Web scraping: 23 articles analyzed
✅ Trends identified: 5 key themes
✅ Presentation generated: https://...
📊 Top Trend: GPT-5 announcement generating significant discussion
Slack Integration
Setup:
Configure Slack webhook for cron job notifications
Webhook URL: https://hooks.slack.com/services/...
Channel: #ai-briefings
Configure Slack webhook for cron job notifications
Webhook URL: https://hooks.slack.com/services/...
Channel: #ai-briefings
Rich formatting:
{
"blocks": [
{
"type": "header",
"text": "Daily Briefing Ready"
},
{
"type": "section",
"text": "47 tweets analyzed, 5 trends identified"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": "View Presentation",
"url": "https://..."
}
]
}
]
}
{
"blocks": [
{
"type": "header",
"text": "Daily Briefing Ready"
},
{
"type": "section",
"text": "47 tweets analyzed, 5 trends identified"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": "View Presentation",
"url": "https://..."
}
]
}
]
}
Email Notifications
Setup:
Configure email notifications for cron job failures
Email: [email protected]
Send on: failure only
Configure email notifications for cron job failures
Email: [email protected]
Send on: failure only
Failure notification:
Subject: Cron Job Failed - Daily Briefing
Job: daily_briefing
Scheduled: 7:00 AM
Failed at: 7:03 AM
Error: Twitter API rate limit exceeded
Action required: Check API limits and retry
Subject: Cron Job Failed - Daily Briefing
Job: daily_briefing
Scheduled: 7:00 AM
Failed at: 7:03 AM
Error: Twitter API rate limit exceeded
Action required: Check API limits and retry
Advanced Use Cases
Use Case 1: Overnight Development
Scenario: Agent works on features while you sleep
Cron jobs:
0 23 * * * - Review codebase, identify improvements
0 0 * * * - Implement feature from backlog
0 2 * * * - Run tests and fix failures
0 4 * * * - Code review and cleanup
0 6 * * * - Generate progress report
0 23 * * * - Review codebase, identify improvements
0 0 * * * - Implement feature from backlog
0 2 * * * - Run tests and fix failures
0 4 * * * - Code review and cleanup
0 6 * * * - Generate progress report
Morning result:
- New feature implemented
- Tests passing
- Code reviewed and cleaned
- Progress report ready
Requirements:
- Claude Code integration
- Comprehensive test suite
- Clear feature specifications in backlog
Use Case 2: Market Monitoring
Scenario: Track competitor activity and market trends
Cron jobs:
0 */6 * * * - Scrape competitor websites
0 8 * * * - Analyze pricing changes
0 9 * * * - Generate competitive intelligence report
0 10 * * 1 - Weekly trend analysis (Mondays only)
0 */6 * * * - Scrape competitor websites
0 8 * * * - Analyze pricing changes
0 9 * * * - Generate competitive intelligence report
0 10 * * 1 - Weekly trend analysis (Mondays only)
Deliverables:
- Real-time competitor tracking
- Pricing change alerts
- Weekly strategic insights
Use Case 3: Content Pipeline
Scenario: Automated content research and drafting
Cron jobs:
0 6 * * * - Research trending topics
0 8 * * * - Draft 3 article outlines
0 10 * * * - Generate first drafts
0 14 * * * - Create social media posts
0 6 * * * - Research trending topics
0 8 * * * - Draft 3 article outlines
0 10 * * * - Generate first drafts
0 14 * * * - Create social media posts
Output:
- Daily content ideas
- Draft articles ready for editing
- Social media content scheduled
Troubleshooting
"Cron job not running"
Diagnosis checklist:
-
Verify cron is scheduled:
List my cron jobsList my cron jobs -
Check time zone:
What time zone are you using?What time zone are you using? -
Test immediately:
Run the daily briefing cron job nowRun the daily briefing cron job now -
Check logs:
Show me logs for the daily briefing cron jobShow me logs for the daily briefing cron job -
Verify API keys:
Test API key configuration for cron environmentTest API key configuration for cron environment
"Cron runs but produces no output"
Possible causes:
-
Skill not found
- Check skill file exists
- Verify skill name matches
-
Data source unavailable
- API rate limits
- Network issues
- Authentication failures
-
Silent failure
- Check error logs
- Add explicit error handling to skill
Solution:
Add error logging to daily briefing skill:
- Log each step completion
- Log any failures with details
- Send notification on failure
Add error logging to daily briefing skill:
- Log each step completion
- Log any failures with details
- Send notification on failure
"Cron job times out"
Cause: Job takes longer than timeout limit
Solutions:
-
Increase timeout:
Set cron job timeout to 60 minutes for daily briefingSet cron job timeout to 60 minutes for daily briefing -
Optimize workflow:
- Use parallel sub-agents
- Cache intermediate results
- Reduce data processing
-
Split into multiple jobs:
Job 1: Data collection (fast) Job 2: Analysis (medium) Job 3: Presentation (fast)Job 1: Data collection (fast) Job 2: Analysis (medium) Job 3: Presentation (fast)
"Notifications not received"
Discord/Slack webhook issues:
-
Verify webhook URL:
Test Discord webhook: https://discord.com/api/webhooks/...Test Discord webhook: https://discord.com/api/webhooks/... -
Check permissions:
- Webhook still active?
- Channel still exists?
- Bot has send permissions?
-
Test manually:
bashcurl -X POST "https://discord.com/api/webhooks/..." \ -H "Content-Type: application/json" \ -d '{"content": "Test notification"}'curl -X POST "https://discord.com/api/webhooks/..." \ -H "Content-Type: application/json" \ -d '{"content": "Test notification"}'
Best Practices
1. Start Simple, Scale Up
Week 1:
One cron job: Daily briefing at 7 AM
One cron job: Daily briefing at 7 AM
Week 2:
Add: Twitter intelligence at 6 AM
Add: Twitter intelligence at 6 AM
Week 3:
Add: Weekly report on Mondays
Add: Weekly report on Mondays
Why: Easier to debug, less overwhelming
2. Test Every Job Before Scheduling
Never:
Schedule for 3 AM → Hope it works → Sleep
Schedule for 3 AM → Hope it works → Sleep
Always:
Schedule for 2 minutes from now → Verify → Then schedule production time
Schedule for 2 minutes from now → Verify → Then schedule production time
3. Monitor and Iterate
After first week:
- Review all cron job outputs
- Identify quality issues
- Update skills to improve results
- Adjust schedules if needed
4. Use Skills for Complex Logic
Bad:
Cron job with 50 lines of inline instructions
Cron job with 50 lines of inline instructions
Good:
Cron job: Execute skill daily_briefing
Skill: Contains all logic and instructions
Cron job: Execute skill daily_briefing
Skill: Contains all logic and instructions
5. Set Up Failure Notifications
Critical jobs:
Send email on failure
Send Discord notification on failure
Log detailed error information
Send email on failure
Send Discord notification on failure
Log detailed error information
Why: Know immediately when something breaks
6. Document Your Cron Jobs
Maintain a cron job registry:
# Cron Job Registry
## Daily Briefing
- Schedule: 0 7 * * *
- Purpose: Generate morning briefing with AI news
- Dependencies: Twitter intelligence (6 AM job)
- Notifications: Discord #daily-briefing
- Owner: @username
## Twitter Intelligence
- Schedule: 0 6 * * *
- Purpose: Collect tweets from monitored accounts
- Dependencies: None
- Notifications: None (silent unless failure)
- Owner: @username
# Cron Job Registry
## Daily Briefing
- Schedule: 0 7 * * *
- Purpose: Generate morning briefing with AI news
- Dependencies: Twitter intelligence (6 AM job)
- Notifications: Discord #daily-briefing
- Owner: @username
## Twitter Intelligence
- Schedule: 0 6 * * *
- Purpose: Collect tweets from monitored accounts
- Dependencies: None
- Notifications: None (silent unless failure)
- Owner: @username
Related Resources
- Skills Optimization [blocked]
- Sub-Agents [blocked]
- Memory Management [blocked]
Duration: 8 minutes
Difficulty: Intermediate
Video Reference: OpenClaw Cron Jobs EXPLAINED