-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux timeout Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
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.
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
Basic usage:
# Run with timeout (10 seconds)
timeout 10 command
# Kills command after 10 secondsSpecify units:
# Seconds (default)
timeout 10 command
# Minutes
timeout 5m command
# Hours
timeout 1h commandSend signal:
# Send TERM signal
timeout 10 command
# Sends TERM, then KILL if neededSpecify signal:
# Custom signal
timeout -s KILL 10 command
# -s = signal (sends KILL immediately)Keep exit status:
# Preserve exit status
timeout --preserve-status 10 command
# Keeps original exit codeForeground execution:
# Run in foreground
timeout --foreground 10 command
# Doesn't create new process groupCheck installation:
# Check timeout
which timeout
# Usually in coreutils
# Install if missing
sudo pacman -S coreutilsThis guide covered timeout usage, time limits, and process control for Arch Linux, CachyOS, and other distributions.
- 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.