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