#!/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) 秒
#!/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) 秒
转载于:https://www.cnblogs.com/lurenjiashuo/p/bash-plus-equal-if-lt-random-sleep.html