zoukankan      html  css  js  c++  java
  • HPUX 只取syslog.log当前三天的信息

    LOG_DAYS=1
    todays_date=`date +%m:%d:%Y`
    current_date=`echo $todays_date | sed 's/://g'`
    day=`echo $todays_date | cut -f 2 -d ":"| sed 's/^0//g'`
    month=`echo $todays_date | cut -f 1 -d ":"| sed 's/^0//g'`
    year=`echo $todays_date | cut -f 3 -d ":"`
    case $LOG_DAYS in
    *[!0-9]* | ???* | 3? | 29) printf -u2 "Invalid input " ; exit 2;;
    esac
    tday=$day
    tmonth=$month
    tyear=$year
    day=$((day - LOG_DAYS))
    if (( day <= 0 )) ; then
    month=$((month - 1))
    if (( month == 0 )) ;then
    year=$((year - 1))
    month=12
    fi
    days=`/usr/bin/cal $month $year`
    xday=`echo $days | awk '{print $NF}'`
    day=$((xday + day))
    fi
    if (( ${#day} == 2 ));then
    day=`echo $day | sed 's/^[1-9]{1}/ &/'`
    else
    day=`echo $day | sed 's/^[1-9]{1}/ &/'`
    fi
    if (( ${#tday} == 2 ));then
    tday=`echo $tday | sed 's/^[1-9]{1}/ &/'`
    else
    tday=`echo $tday | sed 's/^[1-9]{1}/ &/'`
    fi

    month=`cal $month $year | head -n 1 | cut -c 4-6`
    tmonth=`cal $tmonth $year | head -n 1 | cut -c 4-6`

    grep -e "$month$day" -e "$tmonth$tday" /var/adm/syslog/syslog.log | grep -v -e "sshd" -e "ftpd" -e "su:" -e "ETDirect" -e "inetd"

  • 相关阅读:
    生成 n 位验证码的函数
    delphi的procedure of object
    delphi 文本 记录 流式 读写文件
    delphi save .dfm to .txt
    delphi xml
    delphi json
    delphi http server
    dac FDMemTable
    dac oracle
    dac mssql server
  • 原文地址:https://www.cnblogs.com/zlg88/p/5852893.html
Copyright © 2011-2022 走看看