[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5


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:

0 The execution was successfully suspended for at least Seconds seconds, or a SIGALRM signal was received.
>0 An error occurred.

Examples

  1. To run a command after a certain amount of time has passed, enter:

    (
    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.

  2. To run a command at regular intervals, enter:

    while true
    do
     date
     sleep 60
    done
    

    This shell procedure displays the date and time once a minute. To stop it, press the Interrupt key sequence.

Related Information

The shutdown command, wall command.

The alarm subroutine, pause subroutine, sigaction subroutine, sleep subroutine.

Shells Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]