Scheduled Tasks & Loops
Scheduled tasks and loops let MBAgent work automatically on schedule, without you triggering manually each time. This article details how to configure.
1. What Is a Scheduled Task?
Scheduled Task = an MBAgent task auto-triggered at a specific time or interval.
| Trigger Method | Use Scenario |
|---|---|
| Cron expression | 9 AM daily, Monday weekly, 1st of every month, etc. |
| Fixed interval | Every 30 minutes, every 2 hours, every 5 seconds |
| Workspace watcher | Triggered by file changes |
| Manual trigger | Not scheduled, but pre-defined |
2. Create a Scheduled Task
Step 1: Open Scheduled Task Management
In MBAgent main UI, click "Task" → "Scheduled Task" tab, or input slash command:
/schedule listDisplays all current scheduled tasks.
Step 2: New Task
Click the "+" button; the new window pops up:
Step 3: Fill in Task Description
The task description is the prompt that AI receives each time the scheduled task executes. For example:
Aggregate today's order count for all stores, sort by amount descending,
write to reports/orders-{YYYYMMDD}.xlsx.
If there are anomalies (order amount > 10000 or < 1),
send email to alerts@company.com.Step 4: Choose Trigger Method
1. Cron Expression
The most common way. Cron expression syntax:
* * * * *
│ │ │ │ │
│ │ │ │ └── Day of week (0-7, 0=Sunday)
│ │ │ └───── Month (1-12)
│ │ └─────── Day (1-31)
│ └────────── Hour (0-23)
└───────────── Minute (0-59)Common examples:
| Cron | Meaning |
|---|---|
0 9 * * * | Every day 9:00 |
0 9 * * 1-5 | Weekdays 9:00 |
0 0 1 * * | 1st of every month 0:00 |
*/30 * * * * | Every 30 minutes |
0 */2 * * * | Every 2 hours |
0 18 * * 5 | Every Friday 18:00 |
0 0 1 1 * | Every January 1st 0:00 |
2. Fixed Interval
Set how often to execute:
| Field | Description |
|---|---|
| Interval value | Number |
| Interval unit | Second / Minute / Hour / Day |
E.g.: execute once every 30 minutes.
3. Workspace Watcher (watchWorkspace)
Trigger when specified folder content changes:
| Field | Description |
|---|---|
| Watch path | Which folder to watch |
| Event type | New file / Modified file / Deleted file |
| File filter | Filename pattern (e.g. *.xlsx) |
Use scenarios:
- Auto-process when new order files arrive
- Auto re-analyze when data files update
Step 5: Configure Runtime Environment
- Mbbrowser environment: Whether Mbbrowser browser needs to be opened
- Concurrency: Parallelism across multiple environments
- Timeout: Max duration per execution
- Failure handling: How to handle failure
Step 6: Save
Click "Save"; the scheduled task appears in the task list with status "Not enabled".
Step 7: Enable
Select the task and click the "Enable" button. MBAgent will execute automatically per plan.
3. Manage Scheduled Tasks
View All Scheduled Tasks
/schedule listEnable / Pause
- Enable: Select task → click "Enable" button
- Pause: Select task → click "Pause" button (config preserved but not executed)
Delete Task
- Select task
- Click "Delete" button
- Confirm deletion
View Execution History
- Select task
- Click "History" tab
- Displays per execution: trigger time / status / duration / result
Immediate Execution (Manual Trigger)
- Select task
- Click "Run Immediately" button
4. MBAgent Daemon
Daemon = a background resident process that lets scheduled tasks execute per plan even if you haven't actively started MBAgent. mbAgent's daemon supports two background hosts:
- macOS: launchd (write to
~/Library/LaunchAgents/sh.mbagent.scheduler.plist) - Linux: systemd --user (write to
~/.config/systemd/user/mbagent-scheduler.service)
Platform Support Status
| Platform | Status | Description |
|---|---|---|
| macOS | ✅ Supported | Auto launchctl bootstrap gui/$UID on install |
| Linux | ✅ Supported | Generate unit file; user needs to run systemctl --user enable --now themselves |
| Windows | ⏳ Not yet supported | Code explicitly marks "Windows daemon support is deferred"; PID detection in the schedules module returns false directly on Windows, with no launchd / SCM / Windows Service registration branch |
Install Method (macOS / Linux)
- Go to "Settings → Scheduled Tasks"
- Click "Install Daemon" button
- macOS auto
launchctl bootstrap; Linux writes the unit file to~/.config/systemd/user/and prompts thesystemctl --user enable --nowcommand
Daemon Status
MBAgent Scheduler daemon
Status: Running
PID: 12345
pidfile: ~/.local/share/mbagent/scheduler.pid
Loaded tasks: 12Uninstall Daemon
- Go to "Settings → Scheduled Tasks"
- Click "Uninstall Daemon" button
- macOS runs
launchctl bootprint gui/$UID sh.mbagent.scheduler; Linux gives thesystemctl --user disable --nowcommand
WARNING
Pause all scheduled tasks before uninstall, otherwise tasks will fail after uninstall.
NOTE
Windows users: Currently, if you need "unattended" execution of scheduled tasks, you still need to keep the MBAgent main process running. For long-term unattended execution, you can use Windows Task Scheduler to package mbagent schedule tick into a startup auto-run scheduled task (this is a workaround, not mbAgent Daemon).
5. Loop Monitoring (More Advanced)
Loop Task = a simplified version of scheduled task that repeatedly executes at fixed intervals.
Difference from Scheduled Task
| Dimension | Scheduled Task | Loop Task |
|---|---|---|
| Trigger time | Exact time point | Fixed interval |
| Config complexity | High (cron expression) | Low (interval value) |
| Suited scenario | Daily 9 AM run report | Every 30 min check inventory |
| Failure handling | Detailed | Simple |
Create a Loop Task
- Open task panel
- Select "Loop Task" when creating new task
- Set:
- Interval (every X seconds/minutes/hours)
- End condition (stop after N runs / never stop)
- Save and enable
Typical Loop Tasks
- Every 30 minutes check store inventory, notify when below threshold
- Every hour check if Mbbrowser account Token has expired
- Every 5 minutes check email for new orders
- Continuously monitor a webpage for changes
6. Long-Term Goal
Long-term Goal = let MBAgent iterate autonomously around a long-term goal, until the goal is complete or you manually terminate.
Create a Long-term Goal
- Input slash command in MBAgent main UI:
/goal start Continuously optimize the conversion rate of these 20 stores, output weekly analysis report - MBAgent accepts the goal and starts self-planning:
- Week 1: Collect baseline data
- Week 2: Identify low-conversion stores
- Week 3: Formulate optimization plan
- Continuous iteration...
View Long-term Goal Status
/goal statusDisplays:
Goal #1 - Continuously optimize 20-store conversion rate
Status: In progress
Running for: 14 days
Current phase: Week 3 (Optimization plan formulation)
Completion: 45%
Next evaluation: 2026-10-01Stop Long-term Goal
/goal stop7. Research Task
Research Task = MBAgent deeply researches a topic and outputs a structured report.
Create a Research Task
/research start Research the impact of 2026 Amazon new policies on small sellersResearch Flow
[1] Break down research topic
- Sub-topic 1: Full text interpretation of new policy
- Sub-topic 2: Impact on small sellers
- Sub-topic 3: Coping strategies
- Sub-topic 4: Industry cases
↓
[2] Collect materials in parallel
- Call Mbbrowser RAG knowledge base
- Call WebSearch
- Call WebFetch
↓
[3] Analyze and synthesize
- Extract key information
- Verify facts
- Summarize viewpoints
↓
[4] Output report
- Structured Markdown
- Cite sources
- Include chartsView Research Report
- Go to "Research" sidebar
- Select completed research task
- View report
8. Best Practices
Time Selection
✅ Recommended:
- Business off-peak hours (early morning, late night)
- Before Mbbrowser account quota refresh (end of month)
- Mbbrowser browser idle
❌ Avoid:
- Peak hours (daytime working hours)
- Multiple task overlap (CPU / memory too high)
- Cross-timezone sensitive times (e.g. Double 11)
Task Decomposition
✅ Good practice:
- Split large tasks into multiple small scheduled tasks
- Each task focuses on one goal
- Tasks don't depend on each other
❌ Bad practice:
- One big task does too much
- Strong task dependencies (A's failure leads to B's failure)
Error Handling
- ✅ Configure alert notifications (send email / WeChat on failure)
- ✅ Set reasonable timeout (don't wait too long)
- ✅ Keep logs on failure (easier troubleshooting)
Resource Management
- ✅ Limit concurrency (don't let multiple tasks max out CPU)
- ✅ Monitor resource usage (resource monitor in task panel)
- ✅ Important tasks use independent Daemon / independent process (avoid being affected by other tasks; Windows currently has no Daemon, can use independent MBAgent instance to host important tasks)
9. Typical Scenarios
Scenario 1: Daily Sales Report
Task name: Daily sales report
Trigger: Cron 0 9 * * * (every day 9 AM)
Description: Aggregate yesterday's order data from all stores, generate daily report, write to reports/daily-{YYYYMMDD}.xlsx,
and send the daily report content to wechat-bot.Scenario 2: Inventory Monitoring
Task name: Inventory monitoring
Trigger: Fixed interval 30 minutes
Description: Check inventory of all stores, record those below 10 pieces to alerts/low-stock-{YYYYMMDD}.csv,
and email the operations team.
End condition: Run foreverScenario 3: Account Health Patrol
Task name: Account health patrol
Trigger: Cron 0 */6 * * * (every 6 hours)
Description: Check login status, cookie integrity, IP anomalies for all Mbbrowser accounts,
output report to health-check/{YYYYMMDD-HH}.json.
Failure handling: Retry 3 times then skipScenario 4: Auto Data Backup
Task name: Data backup
Trigger: Cron 0 3 * * * (every day 3 AM)
Description: Backup AI memory bank, KMS, all sessions to backup/{YYYYMMDD}/.
End condition: Run forever10. FAQ
Q1: Scheduled task didn't trigger as expected
Troubleshoot:
- Check if cron expression is correct
- Check if MBAgent is running (Windows currently doesn't support Daemon, must keep main process running; macOS/Linux with Daemon installed can trigger unattended)
- Check error info in task history
- Confirm system time is correct
Q2: Tasks don't execute when computer sleeps
Solutions:
- macOS / Linux: Install Daemon (let launchd / systemd-user wake tasks)
- Windows: Currently Daemon not supported; use Windows Task Scheduler + mbagent schedule tick workaround (see NOTE at end of section 4 MBAgent Daemon)
- Set computer not to sleep (Control Panel → Power)
- Set wake timers
Q3: Tasks keep failing
Troubleshoot:
- Run alone once to see error info
- Check if Mbbrowser browser is online
- Check network connection
- Simplify task description, troubleshoot step by step
Q4: Scheduled tasks consume too many Tokens
Solutions:
- Use cheaper model (
gpt-5-mini) - Close "show thinking process"
- Shorten task description
- Reduce execution frequency
Q5: Can scheduled tasks be synced across multiple computers?
Cloud sync not yet supported. Recommend:
- Configure separately on each computer
- Or use a unified task management file + Git sync
Next: Tips & Best Practices → Veteran user experience summary.
