Linux timeout Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
⏱ Linux timeout Guide
Complete beginner-friendly guide to timeout on Linux, covering Arch Linux, CachyOS, and other distributions including limiting command execution time, process timeouts, and command duration control.
Table of Contents
Understanding timeout
What is timeout?
timeout runs command with time limit.
Uses:
- Time limits: Limit command execution
- Prevent hanging: Stop hanging commands
- Process control: Control process duration
- Script safety: Make scripts safer
Why it matters:
- Prevent hangs: Stop hanging processes
- Time control: Control execution time
- Script safety: Make scripts robust
⏱ timeout Basics
Run with Timeout
Basic usage:
# Run with timeout (10 seconds)
timeout 10 command
# Kills command after 10 seconds
Time Units
Specify units:
# Seconds (default)
timeout 10 command
# Minutes
timeout 5m command
# Hours
timeout 1h command
⏰ Time Limits
Kill Signal
Send signal:
# Send TERM signal
timeout 10 command
# Sends TERM, then KILL if needed
Custom Signal
Specify signal:
# Custom signal
timeout -s KILL 10 command
# -s = signal (sends KILL immediately)
Signal Handling
Preserve Status
Keep exit status:
# Preserve exit status
timeout --preserve-status 10 command
# Keeps original exit code
Foreground Mode
Foreground execution:
# Run in foreground
timeout --foreground 10 command
# Doesn't create new process group
Troubleshooting
timeout Not Found
Check installation:
# Check timeout
which timeout
# Usually in coreutils
# Install if missing
sudo pacman -S coreutils
Summary
This guide covered timeout usage, time limits, and process control for Arch Linux, CachyOS, and other distributions.
Next Steps
- watch Guide - Monitor commands
- Process Management - Process management
- timeout Documentation:
man timeout
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.