Commit | Line | Data |
---|---|---|
32424d04 C |
1 | SLEEP(1) BSD Reference Manual SLEEP(1) |
2 | ||
3 | N\bNA\bAM\bME\bE | |
4 | s\bsl\ble\bee\bep\bp - suspend execution for an interval of time | |
5 | ||
6 | S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS | |
7 | s\bsl\ble\bee\bep\bp _\bs_\be_\bc_\bo_\bn_\bd_\bs | |
8 | ||
9 | D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN | |
10 | The s\bsl\ble\bee\bep\bp command suspends execution for a minimum of _\bs_\be_\bc_\bo_\bn_\bd_\bs. S\bSl\ble\bee\bep\bp is | |
11 | used to schedule the execution of other commands (see _\bE_\bX_\bA_\bM_\bP_\bL_\bE_\bS below). | |
12 | ||
13 | The S\bSl\ble\bee\bep\bp utility exits with one of the following values: | |
14 | ||
15 | 0 On successful completion, or if the signal SIGALRM was received. | |
16 | ||
17 | >0 An error occurred. | |
18 | ||
19 | E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS | |
20 | To schedule the execution of a command for _\bx number seconds later: | |
21 | ||
22 | (sleep 1800; sh command_file >& errors)& | |
23 | ||
24 | This incantation would wait a half hour before running the script com- | |
25 | mand_file. (See the at(1) utility.) | |
26 | ||
27 | To reiteratively run a command (with the csh(1)): | |
28 | ||
29 | while (1) | |
30 | if (! -r zzz.rawdata) then | |
31 | sleep 300 | |
32 | else | |
33 | foreach i (`ls *.rawdata`) | |
34 | sleep 70 | |
35 | awk -f collapse_data $i >> results | |
36 | end | |
37 | break | |
38 | endif | |
39 | end | |
40 | ||
41 | The scenario for a script such as this might be: a program currently run- | |
42 | ning is taking longer than expected to process a series of files, and it | |
43 | would be nice to have another program start processing the files created | |
44 | by the first program as soon as it is finished (when zzz.rawdata is cre- | |
45 | ated). The script checks every five minutes for the file zzz.rawdata, | |
46 | when the file is found, then another portion processing is done courte- | |
47 | ously by sleeping for 70 seconds in between each awk job. | |
48 | ||
49 | S\bSE\bEE\bE A\bAL\bLS\bSO\bO | |
50 | setitimer(2), alarm(3), sleep(3), at(1) | |
51 | ||
52 | S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS | |
53 | The s\bsl\ble\bee\bep\bp command is expected to be IEEE Std1003.2 (``POSIX'') compati- | |
54 | ble. | |
55 | ||
56 | 4.4BSD April 18, 1994 1 |