清空日志
#!/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
笃信仁厚,慎思勤勉