1*44957Scael.\" Copyright (c) 1990 The Regents of the University of California. 2*44957Scael.\" All rights reserved. 319469Smckusick.\" 4*44957Scael.\" %sccs.include.redist.man% 543736Scael.\" 6*44957Scael.\" @(#)sleep.1 6.3 (Berkeley) 07/24/90 7*44957Scael.\" 8*44957Scael.Dd 9*44957Scael.Dt SLEEP 1 10*44957Scael.Os BSD 4.4 11*44957Scael.Sh NAME 12*44957Scael.Nm sleep 13*44957Scael.Nd suspend execution for an interval of time 14*44957Scael.Sh SYNOPSIS 15*44957Scael.Nm sleep 16*44957Scael.Ar seconds 17*44957Scael.Sh DESCRIPTION 18*44957ScaelThe 19*44957Scael.Nm sleep 20*44957Scaelcommand 21*44957Scaelsuspends execution for a minimum of 22*44957Scael.Ar seconds . 23*44957Scael.Nm Sleep 24*44957Scaelis used to schedule the execution of other commands (see 25*44957ScaelEXAMPLES below). 26*44957Scael.Pp 27*44957ScaelThe 28*44957Scael.Nm Sleep 29*44957Scaelutility exits with one of the following values: 30*44957Scael.Tw Ds 31*44957Scael.Tp Li \&0 32*44957ScaelOn successful completetion, or if the signal SIGALRM was received. 33*44957Scael.Tp Li \&>\&0 34*44957ScaelAn error occurred. 35*44957Scael.Tp 36*44957Scael.Sh EXAMPLES 37*44957ScaelTo schedule the execution of a command for 38*44957Scael.Va x 39*44957Scaelnumber seconds later: 40*44957Scael.Pp 41*44957Scael.Dl (sleep 1800; sh command_file >& errors)& 42*44957Scael.Pp 43*44957ScaelThis incantation would wait a half hour before 44*44957Scaelrunning the script command_file. (See the 45*44957Scael.Xr at 1 46*44957Scaelutility.) 47*44957Scael.Pp 48*44957ScaelTo reiteratively run a command (with the 49*44957Scael.Xr csh 1 ) : 50*44957Scael.Pp 51*44957Scael.Ds I 52*44957Scaelwhile (1) 53*44957Scael if (! -r zzz.rawdata) then 54*44957Scael sleep 300 55*44957Scael else 56*44957Scael foreach i (`ls *.rawdata`) 57*44957Scael sleep 70 58*44957Scael awk -f collapse_data $i >> results 59*44957Scael end 60*44957Scael break 61*44957Scael endif 62*44957Scaelend 63*44957Scael.De 64*44957Scael.Pp 65*44957ScaelThe scenario for a script such as this might be: a program currently 66*44957Scaelrunning is taking longer than expected to process a series of 67*44957Scaelfiles, and it would be nice to have 68*44957Scaelanother program start processing the files created by the first 69*44957Scaelprogram as soon as it is finished (when zzz.rawdata is created). 70*44957ScaelThe script checks every five minutes for the file zzz.rawdata, 71*44957Scaelwhen the file is found, then another portion processing 72*44957Scaelis done curteously by sleeping for 70 seconds in between each 73*44957Scaelawk job. 74*44957Scael.Sh SEE ALSO 75*44957Scael.Xr setitimer 2 , 76*44957Scael.Xr alarm 3 , 77*44957Scael.Xr sleep 3 , 78*44957Scael.Xr at 1 79*44957Scael.Sh STANDARDS 80*44957ScaelThe sleep function is expected to be POSIX 1003.2 compatible. 81