timeout (coreutils)

CLI

Run 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)

3 of 3 recipes verified by execution · 2026-09-17#timeout#coreutils#hang#portable

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

Verified Linux · 2026-09-17
timeout 10 some-command
Common 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

Verified macOS · 2026-09-17
gtimeout 10 some-command

Run a command with a timeout (portable, no install)

Verified macOS · Linux · 2026-09-17
perl -e 'alarm shift; exec @ARGV' 10 some-command
Common failures (1)
  • exit code is 142 instead of 124perl's alarm kills with SIGALRM (142); treat any non-zero exit as a timeout

Install

Homebrewbrew install coreutils
aptsudo apt install coreutils

Agent notes

When to use
Any command that might block forever; macOS has no timeout binary by default
Quick examples
  • timeout 30 npm test
  • gtimeout 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.

Homepage ↗GPL-3.00 views