shell脚本之日志拆分和监听

#!/bin/bash
M=`date | awk  '{print $2}'`
if
 [ `date +%d` -lt 10   ]
then D=`date +%d | tr -d 0`
else D=`date +%d`
fi
cat /var/log/messages | grep "$M"  | awk '$2 == '$D'' >> /tmp/saved_log/my.log`date +%Y%m%d`
while [ $D -eq `date +%d` ]
do
 cat /var/log/messages | grep "$M"  | awk '$2 == '$D'' >> /tmp/saved_log/my.log`date +%Y%m%d`
 sed  '/'$D'/p' /var/log/messages  > /var/log/messages
 sleep 10s
done

你可能感兴趣的:(linux,监听,shell脚本,休闲,日志拆分)