【问题标题】:How to create a 3 second timer in Bash? [duplicate]如何在 Bash 中创建 3 秒计时器? [复制]
【发布时间】:2019-10-01 18:04:31
【问题描述】:

我用 shell 脚本为 linux 创建了一个任务管理器 我需要每 3 秒刷新一次任务管理器 我在考虑使用 Timer 功能但被卡住了

我写了这些函数:

getnum
print_form
printinfo
move_user_cursor

我将这些函数放入一个主函数中,例如:

init() {
 getnum
 clear
 print_form
 printinfo
 move_user_cursor
}

我的脚本是这样结束的:

init

while true:
 do
  :
done

如何让我的脚本每 3 秒刷新一次?

init(){
  getnum
  clear
  print_form
  printinfo
  move_user_cursor
}

init
while true;
do
  :
done

我期待定时器功能,或睡眠命令

【问题讨论】:

标签: linux bash


【解决方案1】:

替换

init
while true;
do
  :
done

while true;
do
  init
  sleep 3s
done

【讨论】:

  • 我不知道为什么但它不起作用
猜你喜欢
  • 1970-01-01
  • 2012-12-09
  • 1970-01-01
  • 1970-01-01
  • 2020-10-27
  • 1970-01-01
  • 2012-01-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多