brunch

You can make anything
by writing

C.S.Lewis

by Daniel Lim Oct 20. 2016

날짜 기준로그 삭제 와 웹 서비스 상태 확인

Linux TIP - BASH SHELL

1. LOG 삭제


옵션 설명 : 검색된 파일을 삭제 하라

find 명령어를 이용하여  .log 로 끝나고 14일(2주) 넘은 파일 찾기를 실행 하여  결과를 삭제 처리

  $ find /was/apache-tomcat-8.0.33/logs   -mtime  +14   -name " *.log"  -exec rm {} \;


2. 웹 서비스 상태 확인 (wasStatus.sh)


옵션 설명 : RESPONSE CODE 의 값이 200일때 까지 웹서비스를 확인 하라

curl 명령을 이용하여 http://localhost:8080/login 페이지에서 response_code 가 200(성공) 이 표출 될때 까지 10초에 한번식 반복 한다.


#!/bin/bash

WEBPING=0
until [ $WEBPING == "200" ];

do
  echo $WEBPING

  WEBPING=$( curl -sL -w "%{http_code}\\n" "http://localhost:8080/login" -o /dev/null)

  echo --- sleeping for 10 seconds

  sleep 10

done
echo $WEBPING

echo Was is running!



출처 :

1. http://unix.stackexchange.com/questions/13605/how-to-find-files-in-subdirs-and-sort-them-by-filename-in-a-single-command

2. http://stackoverflow.com/questions/12747929/linux-script-with-curl-to-check-webservice-is-up

작가의 이전글 오픈소스 고지 의무에 대하여

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari