![]() ![]() Note that the s suffix is still optional here. This will keep the script waiting for 1 hour, 10 minutes and 5 seconds. You can use more than one suffix and the duration of the sleep is the sum of all the suffix.įor example, if you use the follow command: sleep 1h 10m 5s You are not obliged to use only one suffix at a time. Sleep command with a combination of second, minute, hour and day This could help if you want to run on alternate days or week days. If you want to delay the script in hours, you can do that with the h option: sleep 2hĮven if you want to pause the bash script for days, you can do that with the d suffix: sleep 5d This will pause the script/shell for one minute. You can specify the sleep time in minutes in the following way: sleep 1m Sys 0m0.007s Sleep command with minute or hour or day suffix If you run it with the time command, you’ll see that the bash script actually ran for (a slightly) more than 5 seconds. In a sample bash script, it could look like this: !/bin/bash Suppose you want pause your bash script for 5 seconds, you can use sleep like this: sleep 5 Sleep command without suffix counts in seconds I am going to show the usage of sleep command through sample bash scripts. Though you can use it in a shell directly, the sleep command is commonly used to introduce a delay in the execution of a bash script. Let’s see some examples of the sleep command. Sleep command has a simple syntax: sleep Number So, if you use the sleep command with x and the next command can only be run after x seconds. In other words, it introduces a delay for a specified time. As you can guess from the name, its only function is to sleep. Linux sleep command is one of the simplest commands out there. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |