sleep Command
Purpose
Suspends execution for an interval.
Syntax
sleep Seconds
Description
The sleep command suspends execution of a process for at
least the interval that is specified by the Seconds parameter. The amount of time
that is specified in the Seconds parameter can range from 1 to
MAXINT (2,147,483,647) seconds.
Exit status
This command returns the following exit values:
| Item | Description |
|---|---|
| 0 | The execution was successfully suspended for at least Seconds seconds, or
a SIGALRM signal was received. |
| >0 | An error occurred. |
Examples
- To run a command after a certain amount of time has passed, enter the following command:
( echo "SYSTEM SHUTDOWN IN 10 MINUTES!" | wall sleep 300; echo "SYSTEM SHUTDOWN IN 5 MINUTES!" | wall sleep 240; echo "SYSTEM SHUTDOWN IN 1 MINUTE!" | wall sleep 60; shutdown )&This command sequence warns all users 10 minutes, 5 minutes, and 1 minute before the system is shut down.
- To run a command at regular intervals, enter the following command:
while true do date sleep 60 doneThis shell procedure displays the date and time once a minute. To stop it, press the Interrupt key sequence.