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