bash how to wait seconds


How can we in the script to wait for it until the system completes some tasks? The answer is to use the sleep. This command suspends the script so that the script are low almost no system resources. Timing is sufficient.

Do you want to wait some seconds? In next example, we will wait one second:

sleep 1

To turn off script only for a split second? You can. This example shows the ingested sleep 100ms:

sleep 0.1

In this example, we will wait 20 minutes:

sleep 20m

In next example, we will wait 8 hours:

sleep 8h

Do you want to wait several days? This is possible if you use a parameter d. However, consider using cron scheduler. It is robust. Can you schedule to run it in your scripts at specified times and periodic run.

In last example, we will wait 7 days:

sleep 7d

Bash provides command wait to wait for the process/processes given as arguments:

wait $PID

PID is process ID. 'wait ${!}' waits until the last background process is completed.

Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.