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
🌐
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 ...
Discussions

Loop until success
You could try an until loop. until curl "$arg"; do sleep 10 done It's essentially the same as while ! curl "$arg"; do But nobody ever remembers or cares about the until loop :( More on reddit.com
🌐 r/bash
4
0
March 15, 2024
Why is my command in Interruptible Sleep and how do I wake it?
if it is sleeping, it is something iqtree is doing itself. Nothing to do with bash. It is either locking/awaiting on a resource and sleeping until it becomes available or it is explicitly sleeping. It is likely waiting for an event to occur, at which point it will interrupt itself. More on reddit.com
🌐 r/bash
2
1
February 29, 2024
I am trying to pause or return an output for my bash script, but it keeps on exiting
Neither “pause” nor “return” are native bash commands, as far as I know. If you want to pause a script, you can use the ‘sleep’ function, i.e. sleep 20s will pause the script for 20 seconds. If you want to wait for user interaction, you can do something like read -p “Press ENTER to continue” Which pause the script until the user presses the ENTER key. These are just some examples, some more context about what you’re trying to do may make it easier to provide a specific solution More on reddit.com
🌐 r/linuxquestions
9
2
September 23, 2023
Is sleep in a while true loop acceptable ?
The wait won't take up any CPU resources; the bash process will stay in memory instead of going back and forth like if you'd use cron / systemd. If I wanted to do it cleanly, I'd use cron / systemd and write a timestamp from the script indicating when it was executed. I would use that timestamp in a new execution to know how far back I should go in the logs. That way, your script will work for "any time," and the time interval is controlled by cron / systemd. The benefit would be that others can see when they list systemd jobs that this is running periodically. Those parts will be hidden if you wait. If there is a problem, it will be easier to check logs and see that this job was executed. Is the above needed? It depends. It can be good if it's in an environment with several sysadmins; they'll probably check what is running periodically through systemd. If it's just you or you and a friend, do whatever you think is easiest. More on reddit.com
🌐 r/bash
17
13
January 12, 2023
People also ask

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
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
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
🌐
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.
🌐
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}"
🌐
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
🌐
Linux Hint
linuxhint.com › bash-sleep-command
Bash Sleep Command – Linux Hint
The “sleep” command of Bash is used to stop the execution of the script for a certain period. This command is useful to do any scheduled task or to wait for a certain period before executing a particular script. The command stops the execution of the script for some specific times.
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.
🌐
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.
🌐
Linux Hint
linuxhint.com › sleep_command_linux
Sleep Command in Linux – Linux Hint
In the following example, sleep command is used with while loop. Initially, the value of the variable n is set to 1 and the value of n will be incremented by 1 for 4 times in every 2 seconds interval. So, when will you run the script, each output will appear after waiting 2 seconds. #!/bin/bash n=1 while [ $n -lt 5 ] do echo "The value of n is now $n" sleep 2s echo " " ((n=$n+1)) done
🌐
Baeldung
baeldung.com › home › scripting › guide to linux sleep command with examples
Guide to Linux sleep Command With Examples | Baeldung on Linux
May 14, 2024 - #!/bin/bash trap 'echo "SIGINT trapped"; exit 0' SIGINT trap 'echo "SIGTERM trapped"; exit 0' SIGTERM sleep inf & wait $! # Waits for the completion of the sleep command executed in background
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › what does the sleep command do in linux?
What does the sleep command do in Linux? - nixCraft
December 13, 2022 - Run it as follows (see how to run shell script in Linux for more information): $ chmod +x sleep-demo.sh $ ./sleep-demo.sh ... The shell script will start by showing current time on screen.
🌐
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, ...
🌐
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.
🌐
IONOS
ionos.com › digital guide › server › configuration › linux sleep command
How to use the Linux sleep command - IONOS
October 27, 2023 - If you want to execute a sub­se­quent command, use an AND operation (“&&”). You’ll find an example of this below. The syntax of Linux sleep is as follows: $ sleep [Number] [Suffix]bash ·
🌐
Baeldung
baeldung.com › home › processes › infinite sleep for infinite blocking in bash
Infinite Sleep for Infinite Blocking in Bash | Baeldung on Linux
May 16, 2024 - Thus, we can use the while loop to initiate an infinite sleep in Bash and block a process entirely: ... This loop will execute the sleep 1 command repeatedly, indefinitely putting the shell to sleep for one second at a time.
🌐
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....
🌐
Linux Handbook
linuxhandbook.com › bash-sleep
Using Linux Sleep Command in Bash Scripts
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.
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.