Skip to content

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 MethodUse Scenario
Cron expression9 AM daily, Monday weekly, 1st of every month, etc.
Fixed intervalEvery 30 minutes, every 2 hours, every 5 seconds
Workspace watcherTriggered by file changes
Manual triggerNot 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 list

Displays all current scheduled tasks.

Step 2: New Task ​

Click the "+" button; the new window pops up:

New Scheduled Task
Task name:________________
Task description:____________________________
Trigger method:○ Cron○ Fixed interval○ Watcher
Cron expression:________________
[Tip: 0 9 * * * means every day at 9 AM]
Mbbrowser environment: Auto / Specify / Tag
Concurrency: 5
Timeout: 300 seconds
Failure handling:○ Retry 3 times○ Skip○ Abort

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:

CronMeaning
0 9 * * *Every day 9:00
0 9 * * 1-5Weekdays 9:00
0 0 1 * *1st of every month 0:00
*/30 * * * *Every 30 minutes
0 */2 * * *Every 2 hours
0 18 * * 5Every Friday 18:00
0 0 1 1 *Every January 1st 0:00

2. Fixed Interval ​

Set how often to execute:

FieldDescription
Interval valueNumber
Interval unitSecond / Minute / Hour / Day

E.g.: execute once every 30 minutes.

3. Workspace Watcher (watchWorkspace) ​

Trigger when specified folder content changes:

FieldDescription
Watch pathWhich folder to watch
Event typeNew file / Modified file / Deleted file
File filterFilename 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 list

Enable / Pause ​

  • Enable: Select task → click "Enable" button
  • Pause: Select task → click "Pause" button (config preserved but not executed)

Delete Task ​

  1. Select task
  2. Click "Delete" button
  3. Confirm deletion

View Execution History ​

  1. Select task
  2. Click "History" tab
  3. Displays per execution: trigger time / status / duration / result

Immediate Execution (Manual Trigger) ​

  1. Select task
  2. 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 ​

PlatformStatusDescription
macOS✅ SupportedAuto launchctl bootstrap gui/$UID on install
Linux✅ SupportedGenerate unit file; user needs to run systemctl --user enable --now themselves
Windows⏳ Not yet supportedCode 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) ​

  1. Go to "Settings → Scheduled Tasks"
  2. Click "Install Daemon" button
  3. macOS auto launchctl bootstrap; Linux writes the unit file to ~/.config/systemd/user/ and prompts the systemctl --user enable --now command

Daemon Status ​

MBAgent Scheduler daemon
  Status: Running
  PID: 12345
  pidfile: ~/.local/share/mbagent/scheduler.pid
  Loaded tasks: 12

Uninstall Daemon ​

  1. Go to "Settings → Scheduled Tasks"
  2. Click "Uninstall Daemon" button
  3. macOS runs launchctl bootprint gui/$UID sh.mbagent.scheduler; Linux gives the systemctl --user disable --now command

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 ​

DimensionScheduled TaskLoop Task
Trigger timeExact time pointFixed interval
Config complexityHigh (cron expression)Low (interval value)
Suited scenarioDaily 9 AM run reportEvery 30 min check inventory
Failure handlingDetailedSimple

Create a Loop Task ​

  1. Open task panel
  2. Select "Loop Task" when creating new task
  3. Set:
    • Interval (every X seconds/minutes/hours)
    • End condition (stop after N runs / never stop)
  4. 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 ​

  1. Input slash command in MBAgent main UI:
    /goal start Continuously optimize the conversion rate of these 20 stores, output weekly analysis report
  2. 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 status

Displays:

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-01

Stop Long-term Goal ​

/goal stop

7. 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 sellers

Research 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 charts

View Research Report ​

  1. Go to "Research" sidebar
  2. Select completed research task
  3. 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 forever

Scenario 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 skip

Scenario 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 forever

10. FAQ ​

Q1: Scheduled task didn't trigger as expected ​

Troubleshoot:

  1. Check if cron expression is correct
  2. Check if MBAgent is running (Windows currently doesn't support Daemon, must keep main process running; macOS/Linux with Daemon installed can trigger unattended)
  3. Check error info in task history
  4. Confirm system time is correct

Q2: Tasks don't execute when computer sleeps ​

Solutions:

  1. macOS / Linux: Install Daemon (let launchd / systemd-user wake tasks)
  2. Windows: Currently Daemon not supported; use Windows Task Scheduler + mbagent schedule tick workaround (see NOTE at end of section 4 MBAgent Daemon)
  3. Set computer not to sleep (Control Panel → Power)
  4. Set wake timers

Q3: Tasks keep failing ​

Troubleshoot:

  1. Run alone once to see error info
  2. Check if Mbbrowser browser is online
  3. Check network connection
  4. Simplify task description, troubleshoot step by step

Q4: Scheduled tasks consume too many Tokens ​

Solutions:

  1. Use cheaper model (gpt-5-mini)
  2. Close "show thinking process"
  3. Shorten task description
  4. Reduce execution frequency

Q5: Can scheduled tasks be synced across multiple computers? ​

Cloud sync not yet supported. Recommend:

  1. Configure separately on each computer
  2. Or use a unified task management file + Git sync

Next: Tips & Best Practices → Veteran user experience summary.