Skip to content

Linux sleep Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux sleep Guide

Complete beginner-friendly guide to sleep on Linux, covering Arch Linux, CachyOS, and other distributions including delays, script pauses, and timing operations.


Table of Contents

  1. sleep Basics
  2. Delays
  3. Script Usage
  4. Multiple Delays
  5. Troubleshooting

sleep Basics

Simple Delay

Basic usage:

# Sleep for seconds
sleep 5

# Waits 5 seconds

In Scripts

Script delay:

#!/bin/bash
echo "Starting..."
sleep 3
echo "Done!"

⏱ Delays

Seconds

Basic delay:

# Sleep 5 seconds
sleep 5

# Waits 5 seconds

Minutes

Longer delay:

# Sleep 2 minutes
sleep 2m

# m = minutes

Script Usage

Loop Delay

Delay in loop:

#!/bin/bash
for i in {1..5}; do
    echo "Iteration $i"
    sleep 1
done

Conditional Delay

Wait for condition:

#!/bin/bash
while ! ping -c 1 server; do
    echo "Waiting for server..."
    sleep 5
done

Multiple Delays

Sum Delays

Add delays:

# Sleep 1 minute 30 seconds
sleep 1m 30s

# Sums delays: 90 seconds total

Different Units

Mixed units:

# Sleep 1 hour 30 minutes 15 seconds
sleep 1h 30m 15s

# All units supported

Troubleshooting

sleep Not Found

Check installation:

# sleep is part of coreutils
# Usually pre-installed

# Check sleep
which sleep

Summary

This guide covered sleep usage, delays, and script timing 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