'\" te .\" Copyright (c) 2007, 2011, Oracle and/or its affiliates.All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH sleep 1 "2011 年 7 月 28 日" "SunOS 5.11" "用户命令" .SH 名称 sleep \- 以一定的时间间隔暂停执行 .SH 用法概要 .LP .nf \fB/usr/bin/sleep\fR \fIinterval\fR[\fBd|h|m|s\fR]... .fi .SH 描述 .sp .LP \fBsleep\fR 至少在 \fIseconds\fR 指定的时间(以秒为单位)内暂停执行,或将其暂停至收到 \fBSIGALRM\fR 信号为止。\fIseconds\fR 操作数可采用浮点数的形式指定,但实际粒度通常取决于底层系统。 .SH 操作数 .sp .ne 2 .mk .na \fB\fIinterval\fR\fR .ad .RS 12n .rt 用于指定暂停执行的持续时间的浮点数。该浮点数可采用 C99/XPG6 所需要的所有格式来指定,包括 \fBInf\fR 或 \fBinfinite\fR 等常量。可以有选择地指定四种后缀之一,用来表示该数值是以天 (\fBd\fR)、小时 (\fBh\fR)、分钟 (\fBm\fR) 还是秒 (\fBs\fR) 为单位。如果不带后缀,则假定时间间隔以秒为单位。如果指定了多个时间间隔,它们将累加在一起。单个时间间隔可以为负值,但其总和必须大于等于零。 .RE .SH 示例 .LP \fB示例 1 \fR暂停命令执行 .sp .LP 以下示例在一定的时间之后执行命令: .sp .in +2 .nf example% \fB(sleep 105; \fIcommand\fR)&\fR .fi .in -2 .sp .LP \fB示例 2 \fR不定期执行命令 .sp .LP 以下示例不定期执行命令: .sp .in +2 .nf example% \fBwhile true do \fIcommand\fR sleep 37 done\fR .fi .in -2 .sp .LP \fB示例 3 \fR永久暂停命令执行 .sp .LP 以下示例永久暂停执行命令,或暂停至收到 \fBSIGALRM\fR 信号为止: .sp .in +2 .nf example% sleep Inf .fi .in -2 .sp .LP \fB示例 4 \fR持续 0.5 秒暂停执行命令 .sp .LP 使用表示值 \fB0.5\fR 的备用浮点数形式,持续 0.5 秒暂停执行命令: .sp .in +2 .nf example% printf "%a\en" 0.5 0x1.0000000000000000000000000000p-01 .fi .in -2 .sp .sp .in +2 .nf example% sleep 0x1.0000000000000000000000000000p-01 .fi .in -2 .sp .LP \fB示例 5 \fR持续 23 小时暂停执行命令 .sp .LP 以下示例使用字母后缀,持续 23 小时暂停执行命令: .sp .in +2 .nf example% sleep 1d -1h .fi .in -2 .sp .SH 环境变量 .sp .LP 有关影响 \fBsleep\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 已成功暂停执行命令,至少持续 \fItime\fR 秒,或直至收到 \fBSIGALRM\fR 信号(请参见“附注”部分)。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBwait\fR(1)、\fBalarm\fR(2)、\fBsleep\fR(3C)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP 如果 \fBsleep\fR 实用程序收到 \fBSIGALRM\fR 信号,将执行以下操作之一: .RS +4 .TP .ie t \(bu .el o 以零退出状态正常终止。 .RE .RS +4 .TP .ie t \(bu .el o 有效的忽略该信号。 .RE .sp .LP \fBsleep\fR 实用程序对所有其他信号执行标准操作。