bash中变量+=,if大小判断,随机休眠

#!/bin/bash

index=0
while true;do
    echo "hello"
    (( index+=1))
    echo `date "+%H:%M:%S"`
    if [ $index -ge 5 ];then
        exit
    fi
    sleep "$(( ( RANDOM % 3 )  + 2 ))s"
done

随机时间为 2-5(包含2) 秒

posted @ 2016-11-30 11:34  观海云不远  阅读(534)  评论(0编辑  收藏  举报