log file monitoring by shell script


log file monitoring by shell script
(use for while)

debug 정보를 log에서 1분마다 갱신하여 모니터링하는 shell 을 작성해 보았다

Hint는 http://mcpaint.tistory.com/31 에서 얻었음



#!/bin/bash
# log file info var
LOG_FILE=/log/Debug/ssmweb.log
# temp file info var
LOG_TEMP=/log/Debug/ssmwebtemp.log

CLEAR_TEMP=`> $LOG_TEMP`

while true
do
    # clear screen
    clear

    DT=`date +%Y-%m-%d`
    TIME=`date +%H:%M:%S`

    # echo date
    echo $DT $TIME 'Work'

    cat $LOG_TEMP

    # logfile clear
    echo $CLEAR_TEMP

    # file save command , Must execute background
    STR_GREP=`tail -f $LOG_FILE | grep -i debug > $LOG_TEMP &`

    # execute command
    echo $STR_GREP

    # sleep 1 minute
    sleep 60
    echo 'sleep work'
done

댓글

이 블로그의 인기 게시물

CoreOS Vagrant on Windows.md

The Docker User Guide

Install Docker