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 1To turn off script only for a split second? You can. This example shows the ingested sleep 100ms:
sleep 0.1In this example, we will wait 20 minutes:
sleep 20mIn next example, we will wait 8 hours:
sleep 8hDo 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 7dBash provides command wait to wait for the process/processes given as arguments:
wait $PIDPID 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.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek