| Crates.io | timeout-cli |
| lib.rs | timeout-cli |
| version | 0.1.0 |
| created_at | 2025-08-12 00:53:59.301183+00 |
| updated_at | 2025-08-12 00:53:59.301183+00 |
| description | A simple and reliable command-line timeout utility |
| homepage | https://github.com/yaleman/timeout-cli |
| repository | https://github.com/yaleman/timeout-cli |
| max_upload_size | |
| id | 1791237 |
| size | 68,607 |
A simple and reliable command-line timeout utility written in Rust.
timeout-cli runs a command with a specified time limit. If the command completes within the timeout period, it returns the command's exit code. If the timeout is exceeded, it terminates the command and returns exit code 124 (following standard timeout behavior).
Install prebuilt binaries without compilation:
cargo binstall timeout-cli
This downloads prebuilt binaries from GitHub releases, making installation much faster than compiling from source.
cargo install timeout-cli
Download prebuilt binaries for your platform from the releases page.
Available for:
git clone https://github.com/yaleman/timeout-cli.git
cd timeout-cli
cargo build --release
The binary will be available at target/release/timeout.
timeout [OPTIONS] <SECONDS> <COMMAND> [ARGS]...
<SECONDS> - Number of seconds to wait before timing out<COMMAND> - Command to execute[ARGS]... - Arguments to pass to the command-k, --kill-after <SECONDS> - Also send KILL signal after this many additional seconds# Run echo with a 5-second timeout
timeout 5 echo "Hello World"
# Output: Hello World
# Exit code: 0
# List directory contents with timeout
timeout 10 ls -la /home
# Run a command that might hang
timeout 30 curl -s https://httpbin.org/delay/5
# Send TERM signal after 5 seconds, then KILL signal after 2 more seconds
timeout 5 --kill-after 2 sleep 20
# First sends SIGTERM at 5s, then SIGKILL at 7s if still running
# Exit code: 137 (if killed with KILL signal)
# This will timeout after 2 seconds
timeout 2 sleep 10
# Exit code: 124
# This will complete normally
timeout 10 sleep 2
# Exit code: 0
# Command that exits with specific code
timeout 5 sh -c "exit 42"
# Exit code: 42
# Non-existent command
timeout 5 nonexistent-command
# Exit code: 127 (command not found)
# Permission denied
timeout 5 /root/some-restricted-file
# Exit code: 126 (cannot invoke)
# Commands with multiple arguments and spaces
timeout 15 sh -c "echo 'Processing...'; sleep 3; echo 'Done!'"
# Pipeline commands (wrap in shell)
timeout 10 sh -c "ps aux | grep timeout"
Run the comprehensive test suite:
cargo test
The test suite includes 17+ integration tests covering:
Found a bug or have a feature request? Please open an issue on GitHub.
When reporting issues, please include:
# Clone the repository
git clone <repository-url>
cd timeout-cli
# Run tests
cargo test
# Build for development
cargo build
# Build optimized release
cargo build --release
This project is licensed under the MIT License - see the LICENSE file for details.
This tool aims to be compatible with the standard Unix timeout command:
| Feature | timeout-cli | GNU timeout |
|---|---|---|
| Basic timeout functionality | ✅ | ✅ |
| Exit code 124 for timeouts | ✅ | ✅ |
| Exit code forwarding | ✅ | ✅ |
| Advanced exit codes (125, 126, 127, 137) | ✅ | ✅ |
Kill after additional time (--kill-after) |
✅ | ✅ |
| Signal handling options | ⏳ | ✅ |
| Preserve exit status | ⏳ | ✅ |
| Verbose output | ⏳ | ✅ |
| Duration suffixes (m, h, d) | ⏳ | ✅ |