xref: /freebsd/bin/sleep/sleep.1 (revision 22307be5c958e5b0a5ea1f0f0b303fe359ea02f9)
14b88c807SRodney W. Grimes.\" Copyright (c) 1990, 1993, 1994
24b88c807SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
34b88c807SRodney W. Grimes.\"
44b88c807SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
54b88c807SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
64b88c807SRodney W. Grimes.\"
74b88c807SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
84b88c807SRodney W. Grimes.\" modification, are permitted provided that the following conditions
94b88c807SRodney W. Grimes.\" are met:
104b88c807SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
114b88c807SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
124b88c807SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
134b88c807SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
144b88c807SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
154b88c807SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
164b88c807SRodney W. Grimes.\"    must display the following acknowledgement:
174b88c807SRodney W. Grimes.\"	This product includes software developed by the University of
184b88c807SRodney W. Grimes.\"	California, Berkeley and its contributors.
194b88c807SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
204b88c807SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
214b88c807SRodney W. Grimes.\"    without specific prior written permission.
224b88c807SRodney W. Grimes.\"
234b88c807SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
244b88c807SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
254b88c807SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
264b88c807SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
274b88c807SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
284b88c807SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
294b88c807SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
304b88c807SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
314b88c807SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
324b88c807SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
334b88c807SRodney W. Grimes.\" SUCH DAMAGE.
344b88c807SRodney W. Grimes.\"
354b88c807SRodney W. Grimes.\"	@(#)sleep.1	8.3 (Berkeley) 4/18/94
362a456239SPeter Wemm.\" $FreeBSD$
374b88c807SRodney W. Grimes.\"
384b88c807SRodney W. Grimes.Dd April 18, 1994
394b88c807SRodney W. Grimes.Dt SLEEP 1
404b88c807SRodney W. Grimes.Os
414b88c807SRodney W. Grimes.Sh NAME
424b88c807SRodney W. Grimes.Nm sleep
434b88c807SRodney W. Grimes.Nd suspend execution for an interval of time
444b88c807SRodney W. Grimes.Sh SYNOPSIS
45ac14c311SRuslan Ermilov.Nm
464b88c807SRodney W. Grimes.Ar seconds
474b88c807SRodney W. Grimes.Sh DESCRIPTION
484b88c807SRodney W. GrimesThe
499ba8bd65SPhilippe Charnier.Nm
504b88c807SRodney W. Grimescommand
514b88c807SRodney W. Grimessuspends execution for a minimum of
524b88c807SRodney W. Grimes.Ar seconds .
5364373ec6SRuslan Ermilov.Pp
5464373ec6SRuslan ErmilovIf the
5564373ec6SRuslan Ermilov.Nm
5664373ec6SRuslan Ermilovcommand receives a signal, it takes the standard action.
57ac14c311SRuslan Ermilov.Sh IMPLEMENTATION NOTES
5864373ec6SRuslan ErmilovThe
5964373ec6SRuslan Ermilov.Dv SIGALRM
6064373ec6SRuslan Ermilovsignal is not handled specially by this implementation.
61ac14c311SRuslan Ermilov.Pp
62ac14c311SRuslan ErmilovThe
63ac14c311SRuslan Ermilov.Nm
64ac14c311SRuslan Ermilovcommand will accept and honor a non-integer number of specified seconds
65ac14c311SRuslan Ermilov.Po
66ac14c311SRuslan Ermilovwith a
67ac14c311SRuslan Ermilov.Ql \&.
68ac14c311SRuslan Ermilovcharacter as a decimal point
69ac14c311SRuslan Ermilov.Pc .
70ac14c311SRuslan Ermilov.Bf Sy
71ac14c311SRuslan ErmilovThis is a non-portable extension, and its use will nearly guarantee that
72ac14c311SRuslan Ermilova shell script will not execute properly on another system.
73ac14c311SRuslan Ermilov.Ef
7446be34b9SKris Kennaway.Sh DIAGNOSTICS
754b88c807SRodney W. GrimesThe
76db5b8cafSSteve Price.Nm
774b88c807SRodney W. Grimesutility exits with one of the following values:
784b88c807SRodney W. Grimes.Bl -tag -width flag
794b88c807SRodney W. Grimes.It Li \&0
802028697cSRuslan ErmilovOn successful completion.
814b88c807SRodney W. Grimes.It Li \&>\&0
824b88c807SRodney W. GrimesAn error occurred.
834b88c807SRodney W. Grimes.El
844b88c807SRodney W. Grimes.Sh EXAMPLES
854b88c807SRodney W. GrimesTo schedule the execution of a command for
864b88c807SRodney W. Grimes.Va x
874b88c807SRodney W. Grimesnumber seconds later:
884b88c807SRodney W. Grimes.Pp
894b88c807SRodney W. Grimes.Dl (sleep 1800; sh command_file >& errors)&
904b88c807SRodney W. Grimes.Pp
914b88c807SRodney W. GrimesThis incantation would wait a half hour before
924b88c807SRodney W. Grimesrunning the script command_file. (See the
934b88c807SRodney W. Grimes.Xr at 1
944b88c807SRodney W. Grimesutility.)
954b88c807SRodney W. Grimes.Pp
964b88c807SRodney W. GrimesTo reiteratively run a command (with the
974b88c807SRodney W. Grimes.Xr csh 1 ) :
984b88c807SRodney W. Grimes.Pp
994b88c807SRodney W. Grimes.Bd -literal -offset indent -compact
1004b88c807SRodney W. Grimeswhile (1)
1014b88c807SRodney W. Grimes	if (! -r zzz.rawdata) then
1024b88c807SRodney W. Grimes		sleep 300
1034b88c807SRodney W. Grimes	else
1044b88c807SRodney W. Grimes		foreach i (`ls *.rawdata`)
1054b88c807SRodney W. Grimes			sleep 70
1064b88c807SRodney W. Grimes			awk -f collapse_data $i >> results
1074b88c807SRodney W. Grimes		end
1084b88c807SRodney W. Grimes		break
1094b88c807SRodney W. Grimes	endif
1104b88c807SRodney W. Grimesend
1114b88c807SRodney W. Grimes.Ed
1124b88c807SRodney W. Grimes.Pp
1134b88c807SRodney W. GrimesThe scenario for a script such as this might be: a program currently
1144b88c807SRodney W. Grimesrunning is taking longer than expected to process a series of
1154b88c807SRodney W. Grimesfiles, and it would be nice to have
1164b88c807SRodney W. Grimesanother program start processing the files created by the first
1174b88c807SRodney W. Grimesprogram as soon as it is finished (when zzz.rawdata is created).
1184b88c807SRodney W. GrimesThe script checks every five minutes for the file zzz.rawdata,
1194b88c807SRodney W. Grimeswhen the file is found, then another portion processing
1204b88c807SRodney W. Grimesis done courteously by sleeping for 70 seconds in between each
1214b88c807SRodney W. Grimesawk job.
1224b88c807SRodney W. Grimes.Sh SEE ALSO
12322307be5SRuslan Ermilov.Xr nanosleep 2 ,
12422307be5SRuslan Ermilov.Xr sleep 3
1254b88c807SRodney W. Grimes.Sh STANDARDS
1264b88c807SRodney W. GrimesThe
1279ba8bd65SPhilippe Charnier.Nm
1284b88c807SRodney W. Grimescommand is expected to be
1294b88c807SRodney W. Grimes.St -p1003.2
1304b88c807SRodney W. Grimescompatible.
131