본문 바로가기

new/new dev

쉴 스크립트 sample

#! /bin/sh

while [ true ] 
do
    now=$(date +%H%M)
    if [ $now -eq '1051' ]; then  #10:51
        LOG=$(curl http://localhost/Calculate?count=1\&chg_id=idid\&include_blank=true)
        echo -e $(date) '-' $LOG >> test.log
        sleep 60
    elif [ $now -ge '1100' -a $now -lt '1900' ]; then  #11:00 ~ 18:59
        LOG=$(curl http://localhost/Calculate?count=1024\&chg_id=idid\&include_blank=false)
        echo -e $(date) '-' $LOG >> test.log
        if [[ "$LOG" == *"Count empty"* ]];then
            echo 'FIND Count empty --> sleep 3600'
            sleep 3600
        fi
    fi
    sleep 1
done

 

  • 무한 루프 while
  • 매일 아침 10시 51분에 한번만 실행되는 로직
    (분단위로 시간 체크 하기에 끝나고 60초 슬립)
  • 그 외 시간대(11:00~18:59)에 실행되는 로직
  • 결과는 파일로 저장
  • 처리해야 할 대상이 없으면 3600초 슬립
  • 1초 간격으로 슬립

'new > new dev' 카테고리의 다른 글

룰렛 만들어 볼까?  (0) 2020.01.29
c# FileInfo  (0) 2020.01.14
gitlab with docker  (0) 2017.06.07
docker + redmine, docker + gitlab  (0) 2017.03.20
docker  (0) 2017.03.18