xref: /freebsd/bin/sleep/sleep.1 (revision 06064893b3c62c648518be78604fac29fc0d9d61)
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.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 4. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)sleep.1	8.3 (Berkeley) 4/18/94
32.\" $FreeBSD$
33.\"
34.Dd April 18, 1994
35.Dt SLEEP 1
36.Os
37.Sh NAME
38.Nm sleep
39.Nd suspend execution for an interval of time
40.Sh SYNOPSIS
41.Nm
42.Ar seconds
43.Sh DESCRIPTION
44The
45.Nm
46command
47suspends execution for a minimum of
48.Ar seconds .
49.Pp
50If the
51.Nm
52command receives a signal, it takes the standard action.
53.Sh IMPLEMENTATION NOTES
54The
55.Dv SIGALRM
56signal is not handled specially by this implementation.
57.Pp
58The
59.Nm
60command will accept and honor a non-integer number of specified seconds
61(with a
62.Ql .\&
63character as a decimal point).
64.Bf Sy
65This is a non-portable extension, and its use will nearly guarantee that
66a shell script will not execute properly on another system.
67.Ef
68.Sh EXAMPLES
69To schedule the execution of a command for
70.Va x
71number seconds later (with
72.Xr csh 1 ) :
73.Pp
74.Dl (sleep 1800; sh command_file >& errors)&
75.Pp
76This incantation would wait a half hour before
77running the script command_file.
78(See the
79.Xr at 1
80utility.)
81.Pp
82To reiteratively run a command (with the
83.Xr csh 1 ) :
84.Pp
85.Bd -literal -offset indent -compact
86while (1)
87	if (! -r zzz.rawdata) then
88		sleep 300
89	else
90		foreach i (`ls *.rawdata`)
91			sleep 70
92			awk -f collapse_data $i >> results
93		end
94		break
95	endif
96end
97.Ed
98.Pp
99The scenario for a script such as this might be: a program currently
100running is taking longer than expected to process a series of
101files, and it would be nice to have
102another program start processing the files created by the first
103program as soon as it is finished (when zzz.rawdata is created).
104The script checks every five minutes for the file zzz.rawdata,
105when the file is found, then another portion processing
106is done courteously by sleeping for 70 seconds in between each
107awk job.
108.Sh DIAGNOSTICS
109.Ex -std
110.Sh SEE ALSO
111.Xr nanosleep 2 ,
112.Xr sleep 3
113.Sh STANDARDS
114The
115.Nm
116command is expected to be
117.St -p1003.2
118compatible.
119.Sh HISTORY
120A
121.Nm
122command appeared in
123.At v4 .
124