CommandLinux / Mac

Chronolock

Set Command Timeout and Kill if Exceeded

Runs a command with a maximum time limit, automatically killing it if execution exceeds the threshold. Essential for CI pipelines and scripts that must not hang indefinitely.

timeout 30s ./long-running-script.sh

Usage Notes

  • Accepts s (seconds), m (minutes), h (hours), d (days)
  • Exit code is 124 when the command times out
  • Use --signal=KILL to send SIGKILL instead of SIGTERM
  • On Mac, install coreutils: brew install coreutils then use gtimeout

Warnings

The process receives SIGTERM by default, which may not stop all processes cleanly. Use --signal=KILL for stubborn processes.

Related Scroll Ideas

  • • Timeout with custom signal handling
  • • Retry command with timeout between attempts
  • • Log timeout events to file