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"

  • 相关阅读:
    模拟展示动态按钮
    模拟界面请求到web服务器
    bean的生命周期
    structs2的action实现方式
    annotation中的Autowired
    华为笔试题练习
    开发工具
    [转]Linux双向链表的知识
    【转】 嵌入式C语言编程中Inline函数的应用
    打印格式化printf
  • 原文地址:https://www.cnblogs.com/zlg88/p/5852893.html
Copyright © 2011-2022 走看看