| 1 | .\" Copyright (c) 1990 The Regents of the University of California. |
| 2 | .\" 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.man% |
| 8 | .\" |
| 9 | .\" @(#)sleep.1 6.5 (Berkeley) %G% |
| 10 | .\" |
| 11 | .Vx |
| 12 | .Dd |
| 13 | .Dt SLEEP 1 |
| 14 | .Os |
| 15 | .Sh NAME |
| 16 | .Nm sleep |
| 17 | .Nd suspend execution for an interval of time |
| 18 | .Sh SYNOPSIS |
| 19 | .Nm sleep |
| 20 | .Ar seconds |
| 21 | .Sh DESCRIPTION |
| 22 | The |
| 23 | .Nm sleep |
| 24 | command |
| 25 | suspends execution for a minimum of |
| 26 | .Ar seconds . |
| 27 | .Nm Sleep |
| 28 | is used to schedule the execution of other commands (see |
| 29 | EXAMPLES below). |
| 30 | .Pp |
| 31 | The |
| 32 | .Nm Sleep |
| 33 | utility exits with one of the following values: |
| 34 | .Tw Ds |
| 35 | .Tp Li \&0 |
| 36 | On successful completetion, or if the signal SIGALRM was received. |
| 37 | .Tp Li \&>\&0 |
| 38 | An error occurred. |
| 39 | .Tp |
| 40 | .Sh EXAMPLES |
| 41 | To schedule the execution of a command for |
| 42 | .Va x |
| 43 | number seconds later: |
| 44 | .Pp |
| 45 | .Dl (sleep 1800; sh command_file >& errors)& |
| 46 | .Pp |
| 47 | This incantation would wait a half hour before |
| 48 | running the script command_file. (See the |
| 49 | .Xr at 1 |
| 50 | utility.) |
| 51 | .Pp |
| 52 | To reiteratively run a command (with the |
| 53 | .Xr csh 1 ) : |
| 54 | .Pp |
| 55 | .Ds I |
| 56 | while (1) |
| 57 | if (! -r zzz.rawdata) then |
| 58 | sleep 300 |
| 59 | else |
| 60 | foreach i (`ls *.rawdata`) |
| 61 | sleep 70 |
| 62 | awk -f collapse_data $i >> results |
| 63 | end |
| 64 | break |
| 65 | endif |
| 66 | end |
| 67 | .De |
| 68 | .Pp |
| 69 | The scenario for a script such as this might be: a program currently |
| 70 | running is taking longer than expected to process a series of |
| 71 | files, and it would be nice to have |
| 72 | another program start processing the files created by the first |
| 73 | program as soon as it is finished (when zzz.rawdata is created). |
| 74 | The script checks every five minutes for the file zzz.rawdata, |
| 75 | when the file is found, then another portion processing |
| 76 | is done curteously by sleeping for 70 seconds in between each |
| 77 | awk job. |
| 78 | .Sh SEE ALSO |
| 79 | .Xr setitimer 2 , |
| 80 | .Xr alarm 3 , |
| 81 | .Xr sleep 3 , |
| 82 | .Xr at 1 |
| 83 | .Sh STANDARDS |
| 84 | The sleep function is expected to be POSIX 1003.2 compatible. |