loop-task
A cross-platform CLI that repeatedly executes a shell command at a human-readable interval.
Inspired by agent loops, but intentionally simple.
Installation
npm install -g loop-task
Or use directly with npx:
npx loop-task 30m npm test
Usage
loop-task [options] <interval> <command>
Basic examples
loop-task 30m npm test
loop-task 1h opencode --prompt '/ob-init'
loop-task 1d node sync.js
With npx
npx loop-task 30m npm test
npx loop-task 1h opencode --prompt '/ob-init'
Options
Options must come before the interval:
--immediate | Run immediately before waiting |
--max-runs <n> | Stop after N executions |
--verbose | Show execution details |
-h, --help | Display help |
-V, --version | Display version |
Examples
Agent workflows
npx loop-task 30m opencode --prompt "search for missing translation text and translate them, 3 maximum" --model "opencode/big-pickle"
Run tests every 30 minutes
loop-task 30m npm test
Run immediately, then every hour
loop-task --immediate 1h npm test
Run up to 5 times then stop
loop-task --max-runs 5 5m npm test
Verbose mode
loop-task --verbose 30m npm test
Shows start/end timestamps, exit code, execution duration, and next scheduled run.
Supported intervals
10s | 10 seconds |
5m | 5 minutes |
1h | 1 hour |
1d | 1 day |
1w | 1 week |
Behavior
- No overlapping: waits for the command to finish before starting the next interval
- Resilient: continues looping even if a command exits with a non-zero code
- Graceful shutdown: finishes current execution on Ctrl+C, then exits cleanly
Development
pnpm install
pnpm run build
pnpm run test
pnpm run lint
License
MIT