monitor_command
Poll a shell command at regular intervals, capture output snapshots, and stop automatically on pattern match, output change, or exit code to track long-running tasks.
Instructions
Run a shell command repeatedly and collect output over time.
USE THIS instead of running commands in a loop yourself — it handles
the polling so you don't burn through your iteration limit.
Examples:
- Monitor a build: command="kubectl get pods", stop_pattern="Running"
- Watch a deploy: command="curl -s http://localhost:8080/health", stop_pattern="ok"
- Track a job: command="squeue -u $USER", stop_pattern="", stop_on_change=true
- Wait for completion: command="cat /tmp/job.status", stop_pattern="DONE"
Args:
command: Shell command to run each interval.
interval_seconds: Seconds between each run (default 10, min 2).
timeout_seconds: Max total seconds to monitor (default 300 = 5 min, max 3600).
stop_pattern: Regex pattern — stop early when output matches this. Leave empty to run until timeout.
stop_on_change: Stop when output changes from the first run.
stop_on_exit_code: Stop when command returns this exit code (default -999 = disabled).
max_snapshots: Max number of output snapshots to keep (default 50). Older ones are dropped.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | ||
| stop_pattern | No | ||
| max_snapshots | No | ||
| stop_on_change | No | ||
| timeout_seconds | No | ||
| interval_seconds | No | ||
| stop_on_exit_code | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |