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