xref: /freebsd/bin/sleep/sleep.1 (revision 2295cae7e606d75016575927c3d8729745abb17a)
19ddb49cbSWarner Losh.\"-
24b88c807SRodney W. Grimes.\" Copyright (c) 1990, 1993, 1994
34b88c807SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
44b88c807SRodney W. Grimes.\"
54b88c807SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
64b88c807SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
74b88c807SRodney W. Grimes.\"
84b88c807SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
94b88c807SRodney W. Grimes.\" modification, are permitted provided that the following conditions
104b88c807SRodney W. Grimes.\" are met:
114b88c807SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
124b88c807SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
134b88c807SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
144b88c807SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
154b88c807SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
16fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
174b88c807SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
184b88c807SRodney W. Grimes.\"    without specific prior written permission.
194b88c807SRodney W. Grimes.\"
204b88c807SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
214b88c807SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
224b88c807SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
234b88c807SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244b88c807SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
254b88c807SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
264b88c807SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
274b88c807SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
284b88c807SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
294b88c807SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
304b88c807SRodney W. Grimes.\" SUCH DAMAGE.
314b88c807SRodney W. Grimes.\"
32*2295cae7SDag-Erling Smørgrav.Dd March 22, 2024
334b88c807SRodney W. Grimes.Dt SLEEP 1
344b88c807SRodney W. Grimes.Os
354b88c807SRodney W. Grimes.Sh NAME
364b88c807SRodney W. Grimes.Nm sleep
374b88c807SRodney W. Grimes.Nd suspend execution for an interval of time
384b88c807SRodney W. Grimes.Sh SYNOPSIS
39ac14c311SRuslan Ermilov.Nm
40d46d907aSMateusz Piotrowski.Ar number Ns Op Ar unit
41*2295cae7SDag-Erling Smørgrav.Op ...
424b88c807SRodney W. Grimes.Sh DESCRIPTION
434b88c807SRodney W. GrimesThe
449ba8bd65SPhilippe Charnier.Nm
45be038c3aSStefan Eßercommand suspends execution for a minimum of
4634978f7eSA. Mallory.Ar number
4734978f7eSA. Malloryseconds (the default, or unit
48*2295cae7SDag-Erling Smørgrav.Li s ) ,
49be038c3aSStefan Eßerminutes (unit
50*2295cae7SDag-Erling Smørgrav.Li m ) ,
5134978f7eSA. Malloryhours (unit
52*2295cae7SDag-Erling Smørgrav.Li h ) ,
5334978f7eSA. Malloryor days (unit
54*2295cae7SDag-Erling Smørgrav.Li d ) .
55*2295cae7SDag-Erling SmørgravIntervals can be written in any form allowed by
56*2295cae7SDag-Erling Smørgrav.Xr strtod 3 .
57*2295cae7SDag-Erling SmørgravIf multiple intervals are given, they are added together.
58*2295cae7SDag-Erling SmørgravIf the final sum is zero or negative,
59*2295cae7SDag-Erling Smørgrav.Nm
60*2295cae7SDag-Erling Smørgravexits immediately.
6164373ec6SRuslan Ermilov.Pp
6264373ec6SRuslan ErmilovIf the
6364373ec6SRuslan Ermilov.Nm
6464373ec6SRuslan Ermilovcommand receives a signal, it takes the standard action.
6567a54762SKonstantin BelousovWhen the
6667a54762SKonstantin Belousov.Dv SIGINFO
6767a54762SKonstantin Belousovsignal is received, the estimate of the amount of seconds left to
6867a54762SKonstantin Belousovsleep is printed on the standard output.
69ac14c311SRuslan Ermilov.Sh IMPLEMENTATION NOTES
7064373ec6SRuslan ErmilovThe
7164373ec6SRuslan Ermilov.Dv SIGALRM
7264373ec6SRuslan Ermilovsignal is not handled specially by this implementation.
736fca4c7cSRuslan Ermilov.Sh EXIT STATUS
746fca4c7cSRuslan Ermilov.Ex -std
754b88c807SRodney W. Grimes.Sh EXAMPLES
76*2295cae7SDag-Erling SmørgravTo run a command after half an hour:
774b88c807SRodney W. Grimes.Pp
78*2295cae7SDag-Erling Smørgrav.Dl (sleep 0.5h; sh command_file >out 2>err)&
794b88c807SRodney W. Grimes.Pp
80*2295cae7SDag-Erling SmørgravThis incantation would wait half an hour before
81*2295cae7SDag-Erling Smørgravrunning the script
82*2295cae7SDag-Erling Smørgrav.Pa command_file .
83*2295cae7SDag-Erling SmørgravSee the
844b88c807SRodney W. Grimes.Xr at 1
85*2295cae7SDag-Erling Smørgravutility for another way to do this.
864b88c807SRodney W. Grimes.Pp
87*2295cae7SDag-Erling SmørgravTo reiteratively run a command:
884b88c807SRodney W. Grimes.Pp
894b88c807SRodney W. Grimes.Bd -literal -offset indent -compact
90*2295cae7SDag-Erling Smørgravwhile :; do
91*2295cae7SDag-Erling Smørgrav	if ! [ -r zzz.rawdata ] ; then
92*2295cae7SDag-Erling Smørgrav		sleep 5m
934b88c807SRodney W. Grimes	else
94*2295cae7SDag-Erling Smørgrav		for i in *.rawdata ; do
954b88c807SRodney W. Grimes			sleep 70
96*2295cae7SDag-Erling Smørgrav			awk -f collapse_data "$i"
97*2295cae7SDag-Erling Smørgrav		done >results
984b88c807SRodney W. Grimes		break
99*2295cae7SDag-Erling Smørgrav	fi
100*2295cae7SDag-Erling Smørgravdone
1014b88c807SRodney W. Grimes.Ed
1024b88c807SRodney W. Grimes.Pp
1034b88c807SRodney W. GrimesThe scenario for a script such as this might be: a program currently
1044b88c807SRodney W. Grimesrunning is taking longer than expected to process a series of
1054b88c807SRodney W. Grimesfiles, and it would be nice to have
1064b88c807SRodney W. Grimesanother program start processing the files created by the first
107*2295cae7SDag-Erling Smørgravprogram as soon as it is finished (when
108*2295cae7SDag-Erling Smørgrav.Pa zzz.rawdata
109*2295cae7SDag-Erling Smørgravis created).
110*2295cae7SDag-Erling SmørgravThe script checks every five minutes for the file
111*2295cae7SDag-Erling Smørgrav.Pa zzz.rawdata ,
1124b88c807SRodney W. Grimeswhen the file is found, then another portion processing
1134b88c807SRodney W. Grimesis done courteously by sleeping for 70 seconds in between each
114*2295cae7SDag-Erling Smørgrav.Xr awk 1
115*2295cae7SDag-Erling Smørgravjob.
1164b88c807SRodney W. Grimes.Sh SEE ALSO
11722307be5SRuslan Ermilov.Xr nanosleep 2 ,
11822307be5SRuslan Ermilov.Xr sleep 3
1194b88c807SRodney W. Grimes.Sh STANDARDS
1204b88c807SRodney W. GrimesThe
1219ba8bd65SPhilippe Charnier.Nm
1224b88c807SRodney W. Grimescommand is expected to be
1234b88c807SRodney W. Grimes.St -p1003.2
1244b88c807SRodney W. Grimescompatible.
125*2295cae7SDag-Erling Smørgrav.Pp
126*2295cae7SDag-Erling SmørgravSupport for non-integer intervals, units other than seconds, and
127*2295cae7SDag-Erling Smørgravmultiple intervals which are added together are non-portable
128*2295cae7SDag-Erling Smørgravextensions first introduced in GNU sh-utils 2.0a (released in 2002).
12991c00818STim J. Robbins.Sh HISTORY
13091c00818STim J. RobbinsA
13191c00818STim J. Robbins.Nm
13291c00818STim J. Robbinscommand appeared in
13391c00818STim J. Robbins.At v4 .
134