

Sleep's default unit of time is seconds, which is why we don't have to specify a unit in the examples above. That's it for the basic usage of the sleep command! What to Keep in Mind When Using the Sleep Command Similarly, you could use a floating point number to represent fractions of seconds. The result of this script will look like this:

This will pause your script for N seconds, with N being either a positive integer or a floating point number.Ĭonsider this basic example: echo "Hello there!"Įcho "Oops! I fell asleep for a couple seconds!" Sleep is a very versatile command with a very simple syntax. To do this, you can use the very straightforward sleep command. For example, you might want the script to wait while a process completes or before retrying a failed command. When you're writing a shell script, you may find that you need it to wait a certain number of seconds before proceeding.
