timeout (coreutils)
CLIRun a command with a time limit. Part of GNU coreutils: built into Linux, 'gtimeout' on macOS after brew install coreutils.
Stop a hanging test, server, or network call after N seconds (exit code 124)
Verified commands
Executed by our harness on the platforms shown; the assertion checked the actual result, not just the exit code.
Run a command with a timeout (Linux)
Linux only
timeout 10 some-commandCommon failures (1)
- on macOS: timeout: command not foundbrew install coreutils and use gtimeout, or the portable perl form
Run a command with a timeout (macOS, after brew install coreutils)
macOS only
gtimeout 10 some-commandRun a command with a timeout (portable, no install)
perl -e 'alarm shift; exec @ARGV' 10 some-commandCommon failures (1)
- exit code is 142 instead of 124perl's alarm kills with SIGALRM (142); treat any non-zero exit as a timeout
Install
Homebrew
brew install coreutilsapt
sudo apt install coreutilsAgent notes
- When to use
- Any command that might block forever; macOS has no timeout binary by default
- Quick examples
timeout 30 npm testgtimeout 30 npm test
Use from an agent
curl -s https://clihub.com/api/tools/timeout | jq '.agentHints.provenRecipes[] | {task, command, verified}'Or call get_tool with slug timeout on the MCP server at https://clihub.com/mcp.