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.\" 324b88c807SRodney W. Grimes.\" @(#)sleep.1 8.3 (Berkeley) 4/18/94 332a456239SPeter Wemm.\" $FreeBSD$ 344b88c807SRodney W. Grimes.\" 35*d46d907aSMateusz Piotrowski.Dd May 25, 2022 364b88c807SRodney W. Grimes.Dt SLEEP 1 374b88c807SRodney W. Grimes.Os 384b88c807SRodney W. Grimes.Sh NAME 394b88c807SRodney W. Grimes.Nm sleep 404b88c807SRodney W. Grimes.Nd suspend execution for an interval of time 414b88c807SRodney W. Grimes.Sh SYNOPSIS 42ac14c311SRuslan Ermilov.Nm 43*d46d907aSMateusz Piotrowski.Ar number Ns Op Ar unit 44*d46d907aSMateusz Piotrowski.Ar ... 454b88c807SRodney W. Grimes.Sh DESCRIPTION 464b88c807SRodney W. GrimesThe 479ba8bd65SPhilippe Charnier.Nm 48be038c3aSStefan Eßercommand suspends execution for a minimum of 4934978f7eSA. Mallory.Ar number 5034978f7eSA. Malloryseconds (the default, or unit 51*d46d907aSMateusz Piotrowski.Cm s ) , 52be038c3aSStefan Eßerminutes (unit 53*d46d907aSMateusz Piotrowski.Cm m ) , 5434978f7eSA. Malloryhours (unit 55*d46d907aSMateusz Piotrowski.Cm h ) , 5634978f7eSA. Malloryor days (unit 57*d46d907aSMateusz Piotrowski.Cm d ) . 58be038c3aSStefan EßerIf multiple arguments are passed, the delay will be the sum of all values. 5964373ec6SRuslan Ermilov.Pp 6064373ec6SRuslan ErmilovIf the 6164373ec6SRuslan Ermilov.Nm 6264373ec6SRuslan Ermilovcommand receives a signal, it takes the standard action. 6367a54762SKonstantin BelousovWhen the 6467a54762SKonstantin Belousov.Dv SIGINFO 6567a54762SKonstantin Belousovsignal is received, the estimate of the amount of seconds left to 6667a54762SKonstantin Belousovsleep is printed on the standard output. 67ac14c311SRuslan Ermilov.Sh IMPLEMENTATION NOTES 6864373ec6SRuslan ErmilovThe 6964373ec6SRuslan Ermilov.Dv SIGALRM 7064373ec6SRuslan Ermilovsignal is not handled specially by this implementation. 71ac14c311SRuslan Ermilov.Pp 72ac14c311SRuslan ErmilovThe 73ac14c311SRuslan Ermilov.Nm 7481cea61fSStefan Eßercommand supports other time units than seconds, 7581cea61fSStefan Eßerhonors a non-integer number of time units to sleep in any form acceptable by 7681cea61fSStefan Eßer.Xr strtod 3 , 7781cea61fSStefan Eßerand accepts more than one delay value. 78be038c3aSStefan EßerThese are non-portable extensions, but they have also been implemented 79be038c3aSStefan Eßerin GNU sh-utils since version 2.0a (released in 2002). 806fca4c7cSRuslan Ermilov.Sh EXIT STATUS 816fca4c7cSRuslan Ermilov.Ex -std 824b88c807SRodney W. Grimes.Sh EXAMPLES 834b88c807SRodney W. GrimesTo schedule the execution of a command for 844b88c807SRodney W. Grimes.Va x 8543d088beSTim J. Robbinsnumber seconds later (with 8643d088beSTim J. Robbins.Xr csh 1 ) : 874b88c807SRodney W. Grimes.Pp 884b88c807SRodney W. Grimes.Dl (sleep 1800; sh command_file >& errors)& 894b88c807SRodney W. Grimes.Pp 904b88c807SRodney W. GrimesThis incantation would wait a half hour before 914e86fcacSSheldon Hearnrunning the script command_file. 924e86fcacSSheldon Hearn(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. 13191c00818STim J. Robbins.Sh HISTORY 13291c00818STim J. RobbinsA 13391c00818STim J. Robbins.Nm 13491c00818STim J. Robbinscommand appeared in 13591c00818STim J. Robbins.At v4 . 136