
bash에서 다음과 같이 while 루프를 갖고 싶습니다.
while read i
do
~/bin/submit_job $i
sleep N
done
sleep N
그러나 나는 N in이 처음에는 짧다가 처음 몇 개의 루프 이후에 점진적으로 증가하기를 바랍니다 . 처음 8초는 1초 정도이고 다음과 같이 초 단위로 증가합니다.
1 1 1 1 1 1 1 1 (first 8 iterations)
2 2 2 2 2 2 2 2
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
...
어떤 아이디어가 있나요?
답변1
테스트를 거쳐 작동 중:
#/bin/bash
sleeptime=1
countsleeps=1
maxcount=8
while read i
do
~/bin/submit_job $i
sleep $sleeptime
let countsleeps++
if ((countsleeps>maxcount))
then
countsleeps=1
let sleeptime*=2
if ((sleeptime>2)) ; then let maxcount*=2 ; fi
fi
done