sleep - UDM Command

Syntax

sleep seconds | hh:mm

Description

The sleep command is used to pause execution of the script.

Two forms are available:

sleep seconds

Sleep for the specified number of seconds.

sleep hh:mm

Sleep until an explicit time in the 24-hour clock.

If an explicit time (hh:mm) is specified that already has occurred on the current day, the script will be paused until that time on the following day.

Parameters

Parameter

Description

seconds

Number of seconds to sleep.

hh:mm

Explicit time to sleep until (based on a 24-hour clock). If the specified time is in the past (based on the current local time in the 24-hour cycle when the sleep command is executed), the script will pause until the specified time on the following day.

Examples

To pause execution for 10 seconds:

sleep 10


To pause execution until 10:30 p.m.:

sleep 22:30


Note

If the explicit time form of the sleep command (sleep hh:mm) is used in a loop (for example, forfiles), iterations following the first sleep command are likely to be in the past (perhaps by 1 second), causing some iterations to sleep until the next day.

For example, consider the following loop:

forfiles src=*.txt sortby=createdate
    # Do some stuff
    ...
    sleep 5:00
end


If the some stuff portion of each iteration of the loop took at least 1 second, the script would sleep for approximately 23 hours, 59 minutes, and 59 seconds, with each iteration following the first.