Skip to content

Linux timeout Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

⏱ 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

  1. Understanding timeout
  2. timeout Basics
  3. Time Limits
  4. Signal Handling
  5. Troubleshooting

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


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally