carey9420

linux下有时候执行需要持续性测试一天执行命令,可以使用repeat重复执行该命令

进入 ~/.bashrc 中编辑一个函数function repeat() 

加入内容如下:


$ vim ~/.bashrc
function repeat() {
number=$1
shift
echo $@
for n in $(seq $number); do
$@
done
}
退出后
$ source ~/.bashrc
repeat  n   COMMAND

 

如果想让每轮执行完毕后等待一个可见时间 可以再加一个参数

function repeat() {

number=$1

second=$2

shift

shift

echo $@

for n in $(seq $number); do

$@

echo "sleep $second"

sleep $second

done

}

 

 

分类:

技术点:

相关文章:

  • 2021-12-24
  • 2022-12-23
  • 2021-08-18
  • 2021-11-27
  • 2023-01-03
  • 2021-06-24
  • 2021-05-05
  • 2021-08-12
猜你喜欢
  • 2021-12-18
  • 2022-12-23
  • 2021-10-31
  • 2021-07-07
  • 2021-07-25
  • 2022-12-23
相关资源
相似解决方案