Build a Better Process

Linux sleep Command Summary with Examples

Linux sleep allows you to pause for a specified amount of time.
  1. Purpose - Learn what sleep is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with sleep.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux sleep, 43 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / sleep-command.html

An ad-free and cookie-free website.

Examples of the Linux sleep Command


Learn to pause shell scripts and processes at the Linux command line.


Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux sleep Command Summary with Examples (3:31)

Video Script

The Command and Why You Need It

Our forty-third word, or command to memorize is sleep from our category System.

sleep allows you to pause for a specified amount of time.

Common Linux sleep Options
-options description
--help Display help screen
number timeframe s for seconds, m for minutes, h for hours, d for days

Recall from the previous two videos we started to focus on time with the calendar, and now we'll discuss the timing of commands.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The sleep command has 2 options and arguments refer to the amount of time you'd like the system to pause.

Like most commands, help is available with double-dash --help. And the syntax for sleep goes like this, first is a number like 10, and next a timeframe like seconds, 10 seconds, or days, for 10 days.

The four timeframes are s for seconds, which is the default, m for minutes, h for hours and d for days. And even though it sounds fantastic, I wouldn't advise sleeping for longer than a day.

So why is sleep an important command? Well, you might like to automate an email, start a backup for just make it seem like you are in the office. And now you know how to do that.


Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's hit sleep 3 and see what happens in 3, 2, 1.

$ sleep 3 $ _

Next, we'll try a sleep for 3 seconds again, except hit 33 by accident.

$ sleep 33 _

Uh oh, now what? Okay, always remember Ctrl-c will stop a process, and you will get your command prompt back.

$ sleep 33 ^C $ _

And last, let's stick with sleep 3 seconds again, but be more deliberate with s. Hit the ; which performs the second command after the first, and do an ls, wait another 2 seconds 2s and exit.

$ sleep 3s; ls; sleep 2s; exit stuff video16.txt video21.txt video26.txt video32.txt video35.txt video38a.txt video40.txt video05.txt video19.txt video23.txt video27.txt video33.txt video36.txt video38b.txt video11.txt video20.txt video24.txt video31.txt video34.txt video37.txt video38c.txt _

Very good, and as always exit closes the terminal window.

A Final Tip

Okay now you know how to use sleep. And you know the syntax for commands, options and arguments.

One last tip about the sleep command. So all joking aside, sleep can be really good for you, especially when we are about to learn about building scripts, soon in this Playlist.

Okay, thanks for visiting today. I hope this was a helpful introduction to the sleep command.

Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:

What's Next?

The timing for this tutorial is best understood with the video on YouTube.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / sleep-command.html

linux sleep command
sleep linux
linux sleep
unix sleep
sleep unix
linux sleep examples
shell script sleep
sleep command
linux wait
shell wait
wait linux
linux pause
shell sleep
bash sleep
linux sleep tutorial
man sleep
bash script sleep
linux sleep examples

A newly-updated free resource. Connect and refer a friend today.