The sleep command in Bash pauses script execution for a specified duration, accepting positive integers or floating-point numbers as the time value. By default, the argument is treated as seconds, but you can append suffixes like m (minutes), h (hours), or d (days) to specify other units.

Syntax and Usage

The basic syntax is sleep NUMBER [SUFFIX] ..., where multiple arguments sum together to define the total wait time.

  • sleep 5 pauses for 5 seconds.

  • sleep 0.5 pauses for half a second (supported by GNU/Linux versions).

  • sleep 1h 30m pauses for 1 hour and 30 minutes.

  • sleep infinity pauses indefinitely without consuming CPU, often used in Docker containers.

Practical Applications

  • Retries: Implement exponential backoff by doubling the delay after each failed attempt.

  • Countdowns: Create timers using a for loop with sleep 1 between iterations.

  • Background Execution: Run sleep 10 & to delay execution non-blocking, then use wait to resume when finished.

  • Interrupting: Press Ctrl+C to send a SIGINT signal to a foreground process, or kill PID for background processes.

TaskCommand
Sleep for 5 secondssleep 5
Sleep for 0.5 secondssleep 0.5
Sleep for 2 minutessleep 2m
Sleep indefinitelysleep infinity
Run in backgroundsleep 10 &

Use the sleep command.

Example:

sleep .5 # Waits 0.5 second.
sleep 5  # Waits 5 seconds.
sleep 5s # Waits 5 seconds.
sleep 5m # Waits 5 minutes.
sleep 5h # Waits 5 hours.
sleep 5d # Waits 5 days.

One can also employ decimals when specifying a time unit; e.g. sleep 1.5s

Answer from RydallCooper on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › bash-sleep-how-to-make-a-shell-script-wait-n-seconds-example-command
Bash Sleep – How to Make a Shell Script Wait N Seconds (Example Command)
September 13, 2021 - The sleep command is a useful way to add pauses in your Bash script. Used in conjunction with other commands, sleep can help you create a timed alarm, run operations in the correct order, space out attempts to connect to a website, and more.
Discussions

shell script - Avoiding busy waiting in bash, without the sleep command - Unix & Linux Stack Exchange
I know I can wait on a condition to become true in bash by doing: while true; do test_condition && break sleep 1 done But it creates 1 sub-process at each iteration (sleep). I could a... More on unix.stackexchange.com
🌐 unix.stackexchange.com
March 17, 2013
Why bash scripts often have excessive 'sleep' commands
Absolutely incorrect usage, no need for it. the command will return when it is finished, and no sooner. The only correct usage I've found for sleep statements is to make my scripts seem more impressive. (Also for making retries/spidering request loop failures not as aggressive) At a couple jobs I've left behind sleeps in commands with the comment: # Pause for dramatic effect sleep 2 Your scripts seem so much more impressive when run by others, vs returning immediately. =) More on reddit.com
🌐 r/sysadmin
25
11
September 9, 2019
bash - How to do nothing forever in an elegant way? - Unix & Linux Stack Exchange
That sleeps for 68 years, this sleeps for 98 centuries: sleep 2147483647d... ... In shells that support them (ksh, zsh, bash4), you can start program as a co-process. More on unix.stackexchange.com
🌐 unix.stackexchange.com
linux - Bash script how to sleep in new process then execute a command - Stack Overflow
So, I was wondering if there was a bash command that lets me fork a process which sleeps for several seconds, then executes a command. Here's an example: sleep 30 'echo executing...' & ^This ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

Does `sleep` use CPU while waiting?
No. The `sleep` command suspends the process and does not consume CPU cycles during the wait period.
🌐
linuxize.com
linuxize.com › home › linux commands › linux sleep command (pause a bash script)
Linux Sleep Command (Pause a Bash Script) | Linuxize
How do I cancel a `sleep` in a script?
Press `Ctrl+C` to send `SIGINT` to the foreground process. For background sleep processes, use `kill PID` where PID is the process ID returned by `$!`.
🌐
linuxize.com
linuxize.com › home › linux commands › linux sleep command (pause a bash script)
Linux Sleep Command (Pause a Bash Script) | Linuxize
Can `sleep` accept decimal values?
Yes. The GNU version of `sleep` (used on Linux) supports floating-point numbers. For example, `sleep 0.5` pauses for half a second. The POSIX specification only requires integer support.
🌐
linuxize.com
linuxize.com › home › linux commands › linux sleep command (pause a bash script)
Linux Sleep Command (Pause a Bash Script) | Linuxize
🌐
Linuxize
linuxize.com › home › linux commands › linux sleep command (pause a bash script)
Linux Sleep Command (Pause a Bash Script) | Linuxize
January 31, 2026 - Then the sleep command pauses the script for 5 seconds. Once the specified time period elapses, the last line prints the current time. ... The following script checks whether a host is online every 5 seconds and notifies you when it becomes reachable: ... #!/bin/bash while : do if ping -c 1 192.168.1.10 &> /dev/null then echo "Host is online" break fi sleep 5 done
Top answer
1 of 8
87

Bash has a "loadable" sleep which supports fractional seconds, and eliminates overheads of an external command:

$ cd bash-3.2.48/examples/loadables
$ make sleep && mv sleep sleep.so
$ enable -f sleep.so sleep

Then:

$ which sleep
/usr/bin/sleep
$ builtin sleep
sleep: usage: sleep seconds[.fraction]
$ time (for f in `seq 1 10`; do builtin sleep 0.1; done)
real    0m1.000s
user    0m0.004s
sys     0m0.004s

The downside is that the loadables may not be provided with your bash binary, so you would need to compile them yourself as shown (though on Solaris it would not necessarily be as simple as above).

As of bash-4.4 (September 2016) all the loadables are now built and installed by default on platforms that support it, though they are built as separate shared-object files, and without a .so suffix. Unless your distro/OS has done something creative (sadly RHEL/CentOS 8 build bash-4.4 with loadable extensions deliberately removed), you should be able to do instead:

[ -z "$BASH_LOADABLES_PATH" ] &&
  BASH_LOADABLES_PATH=$(pkg-config bash --variable=loadablesdir 2>/dev/null)  
enable -f sleep sleep

(The man page implies BASH_LOADABLES_PATH is set automatically, I find this is not the case in the official distribution as of 4.4.12. If and when it is set correctly you need only enable -f filename commandname as required.)

If that's not suitable, the next easiest thing to do is build or obtain sleep from GNU coreutils, this supports the required feature. The POSIX sleep command is minimal, older Solaris versions implemented only that. Solaris 11 sleep does support fractional seconds.

As a last resort you could use perl (or any other scripting that you have to hand) with the caveat that initialising the interpreter may be comparable to the intended sleep time:

$ perl -e "select(undef,undef,undef,0.1);"
$ echo "after 100" | tclsh
2 of 8
183

The documentation for the sleep command from coreutils says:

Historical implementations of sleep have required that number be an integer, and only accepted a single argument without a suffix. However, GNU sleep accepts arbitrary floating point numbers. See Floating point.

Hence you can use sleep 0.1, sleep 1.0e-1 and similar arguments.

Find elsewhere
🌐
Namehero
namehero.com › blog › how-to-use-bash-sleep-and-why
How to Use Bash Sleep and Why
November 6, 2024 - Here's what the "sleep" command does in the bash environment, and how to use it to delay execution or implement code to retry scripts.
🌐
InterServer
interserver.net › home › linux and commands › how to use the sleep command in bash
How to Use the sleep Command in Bash - Interserver Tips
August 4, 2025 - The sleep command in Bash is used to delay the execution of a script or a command for a given period. This duration can be specified in seconds (default), minutes, hours, or days, making it versatile for different timing needs.
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › linux / unix bash script sleep or delay a specified amount of time
Linux / UNIX Bash Script Sleep or Delay a Specified Amount of Time - nixCraft
May 26, 2023 - ## run commmand1, sleep for 1 minute and finally run command2 ## command1 && sleep 1m && command2 ## sleep in bash for loop ## for i in {1..10} do do_something_here sleep 5s done ## run while loop to display date and hostname on screen ## while [ : ] do clear tput cup 5 5 date tput cup 6 5 echo "Hostname : $(hostname)" sleep 1 done
🌐
AlexHost
alexhost.com › home › faq › using the sleep command in bash scripts on linux
Using the Sleep Command in Bash Scripts on Linux
June 19, 2025 - The sleep command is commonly used in scripts where you need to introduce a delay between two commands. Here are a few use cases: Pausing between Commands: Suppose you want to create a script that displays a message, waits for a few seconds, and then displays another message. Here’s how you can do it: #!/bin/bash echo "Starting process..." sleep 5 echo "Process resumed after 5 seconds." echo "Performing further operations..." echo "Process completed."
🌐
IONOS
ionos.com › digital guide › server › configuration › linux sleep command
How to use the Linux sleep command - IONOS
October 27, 2023 - The Linux command sleep is used to pause a process for a specified period of time. How long this pause should last and whether operation is resumed or aborted af­ter­wards is up to the user’s dis­cre­tion.
🌐
Linux Handbook
linuxhandbook.com › bash-sleep
Bash Sleep Command Examples in Linux
July 1, 2021 - Though you can use it in a shell directly, the sleep command is commonly used to introduce a delay in the execution of a bash script.
🌐
Hostinger
hostinger.com › home › tutorials › linux sleep command: syntax, options, and examples
How to use the Linux sleep command
December 22, 2025 - The Linux sleep command pauses script or command executions for a specific time. It is helpful to prevent your system from running a process too soon or too frequently while still keeping it automated.
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to use the linux sleep command with examples
Linux Sleep Command with Examples {Terminal and Bash}
January 27, 2025 - It is possible to assign a variable to specify the sleep command duration. To do that, create an example shell script. Take the following steps: 1. Use a text editor like Vim to create a new script file. For example, type the following command: ... #!/bin/bash SLEEP_INTERVAL="30" CURRENT_TIME=$(date +"%T") echo "Time before sleep: ${CURRENT_TIME}" echo "Sleeping for ${SLEEP_INTERVAL} seconds" sleep ${SLEEP_INTERVAL} CURRENT_TIME=$(date +"%T") echo "Time after sleep: ${CURRENT_TIME}"
🌐
Reddit
reddit.com › r/sysadmin › why bash scripts often have excessive 'sleep' commands
r/sysadmin on Reddit: Why bash scripts often have excessive 'sleep' commands
September 9, 2019 -

Very often you see sleep 1 between commands where seemingly it is not required. For example this script which creates a new user:

mkdir /home/$newuser
chown root:root /home/$newuser
sleep 2
mkdir /home/$newuser/sftproot
sleep 2
chown $newuser:$newuser /home/$newuser/sftproot

Is it just incorrect use of sleep or is there actually some benefit as opposed to just leaving it out?

In some cases it makes sense to wait (like async stuff) but shouldn't most of the programs be done with it as soon as they return something? Sometimes it is also used to give user a chance to see whats going on but for me the example above doesn't make any sense.

🌐
Earthly
earthly.dev › blog › using-sleep
Shell Scripting with sleep: Using Delays Strategically - Earthly Blog
July 19, 2023 - Learn how to strategically use the `sleep` command in shell scripting to introduce delays and control the timing of actions in your Linux scripts. ...
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › sleep-command-in-linux-with-examples
sleep Command in Linux with Examples - GeeksforGeeks
July 19, 2024 - This article covered basic usage ... The Bash `Sleep` Command serves as a pause button, enabling computers to wait for a specified duration before proceeding to the next task in a script....