The Key to Proactivity: Cron Scheduled Task System
From Reactive Chat to Proactive Work
In most scenarios, AI is locked in a "cage" and functions as a strict trigger-response mechanism: If you don't speak, it remains silent.
However, this is not the "intelligent digital assistant" humans dream of. Imagine an ideal scenario:
- Your AI assistant silently crawls server error logs at 4 AM to summarize them.
- At 8:30 AM, while you're brushing your teeth, it sends the core summary to your Telegram.
- After the market closes on Wednesday, it automatically organizes changes in your stock portfolio.
To break the bottleneck of "only working upon receiving commands," OpenClaw utilizes the Cron Scheduled Task Framework, deeply embedded in its heartbeat engine, to grant the AI the ability to transition from reactive (Re-Activity) to proactive (Pro-Activity).
Understanding the Three Types of Time Scheduling
Setting a scheduling strategy in a configuration file is more complex than setting an alarm on a phone. OpenClaw supports three primary time planning methods (Trigger Types):
1. One-time Appointment (at)
Used for handling specific, non-recurring tasks with a clear deadline.
- Use cases: "Remind me to go to a meeting in 30 minutes"; "Run a test script tomorrow afternoon to check for memory leaks."
- It functions like an hourglass in the system; once the countdown finishes, the associated command is pushed into the event queue for execution.
2. Fixed Interval (every)
Addresses the need for simplified, constant-speed, infinite loop scheduling. It doesn't care about the day of the week, just the interval.
- Mechanism: Similar to setting a timer for "run once every 45 minutes."
- Anchor Magic (
anchorMs): If you set it toevery: 1hand the program starts at 15:30, it will trigger at 16:30. If you configure an alignment anchor, you can ensure it executes precisely at "00 minutes past every hour." This is extremely useful for clocking in or generating hourly reports.
3. Star-syntax Control (cron Expression)
The industry standard for complex, production-grade scheduling (Crontab). It supports highly granular and complex logic for time point configuration.
- Usage: For example, starting a task to scrape information only on weekday mornings. It uses the traditional Linux-style five-star
* * * * *syntax:0 9 * * 1-5=> Execute the task command at exactly 9:00 AM, Monday through Friday.
Under the Hood: How the Cron Pipeline Operates
When a scheduled time arrives, what happens deep inside the Agent? Three core modules work in coordination:
- CronStore: A database where tasks and their associated actions are registered and stored.
- CronTimer (Heartbeat Scheduler): The system's heartbeat component that continuously checks which tasks have reached their execution points.
- CronOps (Pipeline Dispatcher & Execution Controller): The terminal controller that takes the extracted action information and hands it over to the LLM to trigger physical actions. Here, it faces a crucial decision point—WHERE should it execute?
Isolation: Main Session vs. Isolated Session
- Dispatch to Main Session: This feels like an "interruption." If the AI is currently chatting with you about a requirement or is stuck in a different context, the scheduled task cuts in: "Hey, I've finished the report; by the way, your train of thought will be interrupted now." The advantage is consistent dialogue memory and instant awareness of the situation.
- Dispatch to Isolated Session: For background-heavy tasks that don't concern the current conversation (e.g., categorizing data and uploading to a disk). To prevent task flows from interfering with your interaction channel, these operations are assigned to a silent, invisible isolated sandbox running in the background. It can even complete the work and then report back through a different channel (like a notification plugin). This is the recommended architecture for most daily automation tasks.
By combining strict time management deployment with sandbox execution in different flows, you gain the foundational capability to build autonomous scrapers or office automation assistants that function without human supervision.