petrel919 发表于 2018-8-28 06:45:31

清空日志shell脚本

#!/bin/bash  
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." >&2
  
exit 1
  
}
  
cat /dev/null > messages
  
echo "Logs cleaned up."
  
exit 0


页: [1]
查看完整版本: 清空日志shell脚本