An ad-free and cookie-free website.
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)
Our forty-third word, or command to memorize is
sleep from our category
sleep allows you to pause for a
specified amount of time.
||Display help screen|
||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).
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.
Next, we'll try a
sleep for 3
seconds again, except hit
Uh oh, now what? Okay, always remember
Ctrl-c will stop a process, and you
will get your command prompt back.
And last, let's stick with
seconds again, but be more deliberate
s. Hit the
; which performs the second command
after the first, and do an
wait another 2 seconds
Very good, and as always
the terminal window.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
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
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
The timing for this tutorial is best understood with the video on YouTube.
calcommand, hit Back.
crontabcommand, click Next.
A newly-updated free resource. Connect and refer a friend today.