您的位置:首页 > 运维架构 > Shell

清除日志shell脚本

2016-06-23 17:58 537 查看
#!/bin/bash
#清除日志脚本

LOG_DIR=/var/log
ROOT_UID=0 #$UID为0的时候,用户具有root用户的权限

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 " >&2
exit 1
}

cat /dev/null >messages &&echo "logs cleaned up"

exit 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  change cannot necessary