Timeout

timeout

Step-in replacement for 'timeout' on systems that lack it. Runs a command and kills it if it is still running after the given duration. Duration suffix: s (seconds, default), m (minutes), h (hours), d (days). Uses perl if available; otherwise uses a shell background process approach.

Arguments

  • $1 (string): Duration with optional suffix, e.g. "30", "5m", "2h"
  • $2 (string): Command and arguments to run

Exit codes

  • 0: Command completed within the timeout
  • 1: Invalid duration argument
  • 77: Command timed out (perl path only)