Linux命令:sleep

将目前动作延迟一段时间

2024-12-31 17:38:42

命令行command

补充说明

sleep命令 暂停指定的时间。

语法

sleep(参数)

参数

时间:指定要暂停时间的长度, 包括如下:

  • 2s: 2秒
  • 2m: 2分钟
  • 2h: 2小时
  • 2d: 2天
  • infinity: 永久

实例

有时在写一些以循环方式运行的监控脚本,设置时间间隔是必不可少的,下面是一个Shell进度条的脚本演示在脚本中生成延时。

#!/bin/bash

b=''
for ((i=0;$i<=100;i++))
 do
 printf "Progress:[%-100s]%d%%\r" $b $i
 sleep 0.1
 b=#$b
 done
echo

评论

静谧以待,您的评论将是点睛之笔

撰写首个评论,启程你的前端奇妙之旅

is a Wiki for programming enthusiasts and professionals, organizing knowledge on programming.

Connect With Me

I have a fair amount of knowledge of Javascript, Typescript, VueJs, and Nuxt. If you have an interesting idea, either open source or paid let's connect.

Sent Mail
© 2024-2025 © . All rights reserved.