sleep in bash (bash sleep)

sleep in bash (bash sleep)

We often may need to add delay in bash scripts for various reasons such as syncing, less frequent monitoring etc., We can achieve it by using “sleep” command as follows:
Usage:
#sleep <number of seconds>
Sleeps for 10 seconds
# sleep 10

[root@dock ~]# for number in {1..4}; do date; sleep 10; done
Sun Sep 24 21:12:13 SGT 2017
Sun Sep 24 21:12:23 SGT 2017
Sun Sep 24 21:12:33 SGT 2017
Sun Sep 24 21:12:43 SGT 2017
[root@dock ~]# 
 
Note that the time printed in each iteration is with 4 seconds delay.

Leave a Reply

Your email address will not be published. Required fields are marked *