In this tutorial we will show you how to write bash sleep script.
Over here we will demonstrate the sleep in bash script function with the date command. By entering the command the system will provide us the date and then will not provide us with the time till the sleep time is over and then will show the time once again in the output.
To understand how this can be done, follow the steps given below.
Step 1 – Insert the date and sleep command
First we will start by entering in the date command followed by a semi colon.
Next, we will enter the sleep command and give it the value 5. This means that there will be a delay of 5 seconds over here. After that, we will enter the date command once more and then execute the bash sleep script.
Step 2 – Preview the output
What this script will basically do is print the date and time first, then wait for 5 seconds and print the date and time once again.
With the script running successfully, you can see that a 5 second delay was made after the sleep function.
And that’s it, this way, from the above steps, you can learn the sleep in bash script function and use it when need be.