清空日志

#!/bin/bash
#-*-coding-*-:utf-8
#清除日志脚本
#定义日志路径:/var/log
LOG_DIR=/var/log
#定义一个变量,用于对比用户的$uid
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "You Mast be useing root to running the script."
exit 1
fi
#如果切换到指定的目录不成功,则给出提示,并退出脚本
cd $LOG_DIR || {
echo "Cannot change to $LOG_DIR directory,Please chack it ."
exit 1
}

cat /dev/null >message && {
echo "Logs cleaned up."
exit 0
}
echo "Logs cleaned up failed."
exit 1

 

posted @ 2017-09-04 17:45  大象无形01  阅读(154)  评论(0编辑  收藏  举报