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