bash + 在 bash 中每 10 分钟打印一次

yae*_*ael 2 linux bash perl shell-scripting

我想每 10 分钟通过 echo 打印以下“仍在进行中,再等 10 分钟”

请建议在 echo 命令之前需要添加什么条件才能每 10 分钟打印一次此行?

备注 - 计数器每个周期(1 秒)增加一,我不想在这个脚本中添加额外的延迟(睡眠命令)!!!!!!

 Until   [    ]
 do
 Counter=1

 sleep 1

  let counter=$counter+1

  [ .... ] &&  echo " still in process wait another 10 min …."

 done 
Run Code Online (Sandbox Code Playgroud)

fak*_*ker 7

使用模运算符(bash 特定语法):

if [ $(($counter % 600)) -eq 0 ] ; then
  echo " still in process wait another 10 min .."
fi
Run Code Online (Sandbox Code Playgroud)

或更便携:

if [ `expr $counter % 600` -eq 0 ] ; then
  echo " still in process wait another 10 min .."
fi
Run Code Online (Sandbox Code Playgroud)