Pandya Asked: 2014-05-16 05:49:34 +0800 CST2014-05-16 05:49:34 +0800 CST 2014-05-16 05:49:34 +0800 CST How do I pause for the specific time between two commands in a script? 772 I want to do something like following: #!/bin/bash command1 <pause for 30 seconds> command2 exit How can I do it? command-line 2 Answers Voted Best Answer TuKsn 2014-05-16T05:56:42+08:002014-05-16T05:56:42+08:00 You can use this in a terminal: command1; sleep 30; command2 In your script: #!/bin/bash command1 sleep 30 command2 exit Suffix for the sleep time: s for seconds (the default) m for minutes h for hours d for days Jose Rosa 2017-08-17T10:34:25+08:002017-08-17T10:34:25+08:00 You can use read -t. E.g: read -p "Continuing in 5 seconds..." -t 5 echo "Continuing..." In your script: command1 read -p 'Pausing for 30 seconds' -t 30 command2 Note that you can press Enter to bypass the timeout period.
You can use this in a terminal:
In your script:
Suffix for the sleep time:
s
for seconds (the default)m
for minutesh
for hoursd
for daysYou can use
read -t
. E.g:In your script:
Note that you can press Enter to bypass the timeout period.