Cron is the time-tested Unix scheduler that has run periodic tasks reliably for decades. The same concept - specifying when tasks should run using a simple expression - applies perfectly to code maintenance. Set up your maintenance tasks once, specify when they should run, and they execute automatically forever.
With AI-powered maintenance scheduled via cron expressions, your codebase maintains itself on a predictable rhythm. Security scans at midnight. Dependency updates every Tuesday. Code quality audits on the first of each month. All running automatically without manual intervention.
Why Cron-Style Scheduling
Cron expressions provide a proven, flexible scheduling system.
Familiar Syntax
Developers already know cron:
* * * * * = minute hour day month weekday
No new scheduling language to learn.
Precise Control
Schedule exactly when you want:
0 2 * * * = 2:00 AM every day
0 9 * * 1 = 9:00 AM every Monday
0 0 1 * * = Midnight on the 1st of each month
Reliable Execution
Cron has run reliably since 1975:
Proven technology for predictable execution
Integration Ready
Works with existing infrastructure:
GitHub Actions, CI systems, and deployment pipelines all support cron
Common Maintenance Schedules
Daily Maintenance
# Security scan at 2 AM
0 2 * * * @devonair scan for security vulnerabilities
# Check for critical updates at 3 AM
0 3 * * * @devonair check for critical dependency updates
# Clean up temporary files at 4 AM
0 4 * * * @devonair cleanup temporary and cache files
Weekly Maintenance
# Dependency updates every Tuesday at 9 AM
0 9 * * 2 @devonair update minor dependencies
# Code quality audit every Monday at 8 AM
0 8 * * 1 @devonair run code quality analysis
# Dead code detection every Friday at 6 PM
0 18 * * 5 @devonair identify dead code
Monthly Maintenance
# Comprehensive audit on the 1st at midnight
0 0 1 * * @devonair run comprehensive code audit
# Major dependency review on the 15th
0 9 15 * * @devonair review major version updates
# Documentation verification on the 1st
0 8 1 * * @devonair verify documentation accuracy
Quarterly Maintenance
# Full security audit at start of quarter
0 0 1 1,4,7,10 * @devonair run full security audit
# Technology stack review
0 9 1 1,4,7,10 * @devonair review technology stack
Setting Up Scheduled Tasks
Define the Task
Specify what should happen:
@devonair schedule task:
name: "Daily Security Scan"
action: scan repositories for security vulnerabilities
on_findings: create issues and notify #security
Set the Schedule
Specify when using cron expression:
@devonair schedule:
cron: "0 2 * * *" # 2 AM daily
task: security-scan
timezone: "America/New_York"
Configure Notifications
Define what happens with results:
@devonair configure notifications:
on_success: post summary to #dev-updates
on_failure: alert #oncall
on_findings: create issues
Cron Expression Reference
Basic Syntax
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday = 0)
│ │ │ │ │
* * * * *
Common Patterns
Every hour:
0 * * * *
Every day at midnight:
0 0 * * *
Every day at 2 AM:
0 2 * * *
Every Monday at 9 AM:
0 9 * * 1
First of each month:
0 0 1 * *
Every 15 minutes:
*/15 * * * *
Weekdays at 9 AM:
0 9 * * 1-5
Weekend at noon:
0 12 * * 0,6
GitHub Actions Integration
GitHub Actions supports cron scheduling natively:
# .github/workflows/maintenance.yml
name: Scheduled Maintenance
on:
schedule:
# Daily at 2 AM UTC
- cron: '0 2 * * *'
# Weekly on Monday at 9 AM UTC
- cron: '0 9 * * 1'
jobs:
maintenance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run maintenance
run: |
@devonair run scheduled-maintenance
Multiple Schedules
Different tasks need different schedules:
@devonair configure schedules:
security:
cron: "0 */4 * * *" # Every 4 hours
task: security-scan
dependencies:
cron: "0 9 * * 2" # Tuesday 9 AM
task: update-dependencies
quality:
cron: "0 8 * * 1" # Monday 8 AM
task: code-quality-audit
cleanup:
cron: "0 0 * * 0" # Sunday midnight
task: dead-code-removal
Timezone Handling
Schedules should respect timezones:
@devonair configure schedule:
cron: "0 9 * * 1"
timezone: "America/Los_Angeles" # 9 AM Pacific
Or use UTC for consistency:
@devonair configure schedule:
cron: "0 17 * * 1"
timezone: "UTC" # 5 PM UTC = 9 AM Pacific
Handling Schedule Conflicts
Non-Overlapping
Ensure tasks don't conflict:
@devonair configure:
- 0 2 * * * task-a
- 0 3 * * * task-b # Start after task-a finishes
Serialization
Prevent parallel execution:
@devonair configure:
task: security-scan
allow_parallel: false
skip_if_running: true
Priority
When tasks compete:
@devonair configure priorities:
security-scan: high # Always runs
quality-audit: medium # Waits for security
cleanup: low # Yields to others
Conditional Scheduling
Skip on Holidays
@devonair configure:
task: dependency-updates
skip_holidays: true
holidays: "US"
Skip During Freezes
@devonair configure:
task: dependency-updates
check_before_run:
- no active code freeze
- not release week
Environment-Specific
@devonair configure:
task: aggressive-cleanup
run_only_in: staging # Not production repo
Monitoring Schedules
Execution History
Track what ran:
@devonair show schedule history:
- security-scan: last run 2h ago ✓
- dependency-update: last run 3d ago ✓
- quality-audit: last run 7d ago ✓
Missed Runs
Detect failures:
@devonair alert when:
- scheduled run misses by > 1 hour
- consecutive failures > 2
Next Runs
Preview upcoming:
@devonair show next runs:
- security-scan: in 4 hours
- dependency-update: in 2 days
- quality-audit: in 5 days
Error Handling
Retry Logic
@devonair configure:
task: security-scan
on_failure:
retry_count: 3
retry_delay: 15m
backoff: exponential
Alerting
@devonair configure:
task: security-scan
on_failure:
alert: "#oncall"
escalate_after: 2 failures
Graceful Degradation
@devonair configure:
task: comprehensive-audit
on_partial_failure:
complete_what_possible: true
report_failures: true
Maintenance Windows
Restrict when maintenance runs:
@devonair configure maintenance window:
allowed_hours: "0-6" # Only 12 AM - 6 AM
allowed_days: "1-5" # Weekdays only
task: dependency-updates
cron: "0 2 * * *" # Will only run if within window
Output Management
Reports
Generate reports on schedule:
@devonair schedule:
cron: "0 9 * * 1"
task: generate-weekly-report
output: post to #engineering
PRs
Create PRs on schedule:
@devonair schedule:
cron: "0 9 * * 2"
task: dependency-updates
output: create PR with changes
Notifications
Notify on completion:
@devonair schedule:
cron: "0 2 * * *"
task: security-scan
notify:
on_findings: "#security"
on_clean: "#dev-updates (daily digest)"
Getting Started
Define your schedules:
@devonair configure scheduled maintenance:
daily:
- security-scan at 2 AM
- build-verification at 3 AM
weekly:
- dependency-updates on Tuesday
- code-quality on Monday
monthly:
- comprehensive-audit on the 1st
Enable monitoring:
@devonair enable schedule monitoring and alerts
Review and adjust:
@devonair review schedule effectiveness monthly
Cron-scheduled maintenance runs reliably in the background, keeping your code healthy without manual intervention. Set it up once and your codebase maintains itself on your schedule.
FAQ
What timezone should I use?
Use your team's timezone for human-visible actions (reports, PRs). Use UTC for background tasks that don't need timezone awareness. Be explicit about timezone in configuration.
How do I prevent maintenance from running during outages?
Add pre-run checks that verify system health. Configure maintenance to skip when incident flags are set. Use feature flags for maintenance that can be disabled quickly.
What if a scheduled task takes longer than expected?
Configure maximum run times. Alert on tasks exceeding expected duration. Prevent overlapping runs of the same task. Consider breaking long tasks into smaller scheduled pieces.
Can I manually trigger scheduled tasks?
Yes, configure tasks to be triggerable both on schedule and manually. This helps with testing and handling urgent needs outside the normal schedule.