The sleep
command in Bash is used to pause the execution of a script or command for a specified amount of time. This can be useful in various scenarios, such as waiting for a process to complete or introducing delays in automated scripts.
The basic syntax of the sleep
command is as follows:
sleep [options] [duration]
Where [duration]
can be specified in seconds, or with a suffix to indicate minutes (m
), hours (h
), or days (d
).
-h
, --help
: Display help information about the command.-V
, --version
: Show the version of the sleep
command.sleep 5
sleep 2m
sleep 1h
sleep 3d
for i in {1..5}; do
echo "Iteration $i"
sleep 1
done
sleep
to create delays between commands in scripts, especially when waiting for resources to become available.sleep
with other commands in a script to manage timing effectively, such as in automated testing or deployment scripts.