.\" Copyright (c) 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the Institute of Electrical and Electronics Engineers, Inc. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sleep.1 8.3 (Berkeley) 4/18/94 .\" %FreeBSD: src/bin/sleep/sleep.1,v 1.15.2.2 2001/08/16 10:01:09 ru Exp % .\" .\" $FreeBSD: doc/ja_JP.eucJP/man/man1/sleep.1,v 1.12 2001/07/29 05:14:52 horikawa Exp $ .\" .Dd April 18, 1994 .Dt SLEEP 1 .Os .Sh 名称 .Nm sleep .Nd 一定の時間実行を停止する .Sh 書式 .Nm .Ar seconds .Sh 解説 .Nm コマンドは、少なくとも .Ar seconds で指定した秒数だけ実行を停止します。 .Pp .Nm コマンドがシグナルを受信すると標準の動作を行います。 .Sh 実装に関する注 この実装においては、 .Dv SIGALRM シグナルは特別には扱われません。 .Pp .Nm コマンドは、非整数の数値で指定された秒数を受け付けて、これを尊重します。 (小数点として .Ql .\& 文字を使用します)。 .Bf Sy これはポータブルではない拡張です。 これを使用するシェルスクリプトは、 他のシステムで正しく実行できないことを、ほぼ保証できます。 .Ef .Sh 診断 .Nm コマンドは終了時に以下の値のいずれかを返します。 .Bl -tag -width flag .It Li \&0 正常終了した場合。 .It Li \&>\&0 エラーが起きた場合。 .El .Sh 使用例 あるコマンドの実行を .Va x 秒後に設定したい場合: .Pp .Dl (sleep 1800; sh command_file >& errors)& .Pp 上記の例では、command_file で指定したスクリプトを実行する前に 30 分間待ちます( .Xr at 1 ユーティリティの項を参照)。 .Pp あるコマンドを( .Xr csh 1 を使って)繰り返し実行したい場合: .Pp .Bd -literal -offset indent -compact while (1) if (! -r zzz.rawdata) then sleep 300 else foreach i (`ls *.rawdata`) sleep 70 awk -f collapse_data $i >> results end break endif end .Ed .Pp このようなスクリプトが必要とされるのは以下のような場合でしょう: 現在実行中のプログラムが、一連のファイル群を処理するのに予想以上の 時間を必要としていて、このプログラムが処理結果をファイル (zzz.rawdata)に出力したらすぐに別のプログラムを起動して そのファイルを処理したほうがよい場合があります。 上記のスクリプトでは、zzz.rawdata が生成されたかどうかを 5 分おきに確認し、生成が確認されたら 70 秒待って awk ジョブを 実行する、という操作を繰り返します。 .Sh 関連項目 .Xr nanosleep 2 , .Xr sleep 3 .Sh 規格 .Nm コマンドは、おそらく .St -p1003.2 互換です。