定时清除 /var/log/massage 下的信息脚本文件

定时清除 /var/log/massage 下的信息脚本

#!/bin/sh
#Date: 0:07
#Author: Xiaodong
#Mail: 990974238@qq.com
#Punction:This scripts function is clean log massage
LOG_DIR=/var/log
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script ."
exit 1
fi
cd $LOG_DIR ||{
echo "Cannot change to necessary directory."
exit 1
}
cat /dev/null>messages && {
echo "Logs cleaned up."
exit 0
}
echo "Logs cleaned up fail."
exit 1

  

上一篇:关于IOC和DI的理解


下一篇:位于/var/log目录下的20个Linux日志文件