Back to Blog

Tutorial

Cron: Scheduled Automation With Arcana

Arcana is not just interactive. The cron system lets you schedule agent tasks that run automatically: daily code reviews, weekly security scans, periodic documentation updates, or any recurring work that benefits from AI automation.

The value of scheduled automation is that it removes the human from the loop for repetitive tasks. You do not need to remember to run the daily code review. You do not need to manually generate the weekly report. Arcana runs on schedule, produces output, and you review the results when it is convenient for you.

This is not about replacing human judgment. It is about automating the gathering and analysis so that human judgment can focus on the decisions that matter. The agent reviews the code; you decide what to do about the findings. The agent generates the report; you decide what actions to take.

Adding a Job

# Add a daily code review job
arcana cron add "review-code" --schedule "0 9 * * *" --prompt "Review all uncommitted changes since yesterday"

# Add a weekly report
arcana cron add "weekly-report" --schedule "0 17 * * 5" --prompt "Generate a summary of this week's commits and open issues"

Schedule Format

Linux / macOS: Schedules use standard cron syntax: minute, hour, day-of-month, month, day-of-week.

# Standard cron syntax
--schedule "0 9 * * 1-5"   # Weekdays at 9am
--schedule "0 17 * * 5"    # Fridays at 5pm
--schedule "0 9 1 * 1"     # First Monday of each month

Windows: Arcana on Windows uses the Windows Task Scheduler internally. You can use the same cron syntax and Arcana translates it, or use natural language which works on all platforms:

# Natural language (works on all platforms)
--schedule "every weekday at 9am"
--schedule "daily at 5pm"
--schedule "first Monday of each month"

Note: On Windows, scheduled tasks run under the Task Scheduler service. Make sure you are logged in or that the task is configured to run whether or not you are logged in.

Job Output

Cron job output is captured and stored locally. You can review past runs:

# List all scheduled jobs
arcana cron list

# Run a job immediately
arcana cron run --id 

CI Usage

Cron jobs integrate with CI pipelines. Run Arcana tasks as part of your build process:

# In a GitHub Actions workflow
- name: AI Code Review
  run: arcana run "review the changes in this PR" --timeout 120 --json > review.json

Adding Jobs via Config

For jobs you want to version control, add them to your config file:

{
  "cron": {
    "jobs": [
      {
        "name": "daily-review",
        "schedule": "0 9 * * *",
        "prompt": "Review uncommitted changes and flag issues"
      }
    ]
  }
}

Best Practices

  • Use --timeout to bound job duration. Unbounded jobs can consume resources. A 120-second timeout is reasonable for most tasks.
  • Keep prompts specific. "Review code" is less useful than "check for security issues in recently changed files." The more specific your prompt, the more focused and useful the output.
  • Store output in a consistent location for monitoring and alerting. Use > /var/log/arcana/daily-review.json or a similar pattern.
  • Test jobs interactively first with arcana run before scheduling them. If the interactive result is not useful, the scheduled result will not be either.
  • Monitor job health. Check arcana cron list regularly to ensure jobs are running. Failed jobs silently consume resources without producing results.
  • Use descriptive job names. daily-security-review is better than job-1 when you are reviewing job history.

Error Handling

Cron jobs handle errors gracefully. If a job fails (provider timeout, network error, quota limit), Arcana logs the failure and continues to the next scheduled run. Failed jobs do not block subsequent runs.

You can configure retry behavior for transient failures:

{
  "cron": {
    "retry": {
      "maxAttempts": 3,
      "backoff": "exponential"
    }
  }
}

This retries failed jobs up to 3 times with exponential backoff. Permanent failures (bad prompt, missing config) are not retried.