shell sleep毫秒_shell中sleep和usleep

本文介绍了shell中的sleep和usleep命令,它们用于暂停进程。sleep命令可以按秒、分钟、小时或天来设定暂停时间,适合定时任务或轮询检查。而usleep则提供微秒级别的暂停,适用于精细的定时或高频轮询。需要注意的是,usleep的精度并不高,不适合精确计时循环。
摘要由CSDN通过智能技术生成

sleep

This is the shell equivalent of a wait loop. It pauses for a

specified number of seconds, doing nothing. It can be useful

for timing or in processes running in the background,

checking for a specific event every so often (polling),

as in Example 29-6.sleep 3 # Pauses 3 seconds.

d0b225b244677470a340d2f028546d15.gifThe sleep command defaults to

seconds, but minute, hours, or days may also be specified.sleep 3 h # Pauses 3 hours!

d0b225b244677470a340d2f028546d15.gifThe watch command may

be a better choice than sleep for running

commands at timed intervals.usleep

Microsleep (the "u"

may be read as the Greek "mu", or micro-

prefix). This is the same as sleep,

above, but "sleeps" in microsecond

intervals. It can be used for fine-grain timing, or for

polling an ongoing process at very frequent intervals.

usleep 30 # Pauses 30 microseconds.

This command is part of the Red Hat initscripts /

rc-scripts package.

efd59df159d1b3aa3c617ee576f3e047.gifThe usleep command does not

provide particularly accurate timing, and is therefore

unsuitable for critical timing loops.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值