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 specified by the Seconds parameter. The amount of time 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:
This command sequence warns all users 10 minutes, 5 minutes, and 1 minute before the system is shut down.( 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 )&
- To run a command at regular
intervals, enter:
This shell procedure displays the date and time once a minute. To stop it, press the Interrupt key sequence.while true do date sleep 60 done