This post will guide you how to use Sleep command from the command line on your Linux operating system. How do I use Sleep comand on a bash shell script.
sleep – delay for a specified amount of time
sleep NUMBER[SUFFIX]... sleep OPTION
Pause for NUMBER seconds. SUFFIX may be ‘s’ for seconds (the default), ‘m’ for minutes, ‘h’ for hours or ‘d’ for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of their values.
--help display this help and exit
--version output version information and exit
Linux Sleep Command Examples
If you want to delay for 20 seconds at the shell promt, type the following command:
$ sleep 20
If you want to delay for 1 hour, type:
$ sleep 1h
If you want to sleep for 15 minutes, type:
$ sleep 15m
You can also use Sleep command in a bash shell script, like below:
#!/bin/bash echo -e "start to sleep 15 seconds......" sleep 15 echo -e "continue to run program......"
Let’s run this shell script with the following command:
[email protected]:~$ ./testSleep.sh start to sleep 15 seconds...... continue to run program......