首页 > 代码库 > 清理messages日志脚本
清理messages日志脚本
要求:
清楚/var/log下messages日志文件的简单命令脚本
要使用root身份来运行这个脚本
清楚日志脚本,版本
#!/bin/bash #清除日志脚本,版本2 LOG_DIR=/var/log ROOT_UID=0 #$UID为0的时候,用户才具有root用户的权限 #要使用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 # || :是或的意思,如果前面执行不成功则会执行后面的 &2:标准错误 exit 1 } cat /dev/null > messages && echo "Logs cleaned up" #清空日志 exit 0
本文出自 “小菜鸟” 博客,请务必保留此出处http://baishuchao.blog.51cto.com/12918589/1937247
清理messages日志脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。