henda 发表于 2018-8-24 10:45:47

shell编程,开始了

#!/bin/bash  
#清除linux日志脚本
  
LOG_DIR=/var/log
  
#$UID为0的时候,用户才真正具有root用户的权限
  
ROOT_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 > message && echo "Logs cleaned up."
  
exit 0


页: [1]
查看完整版本: shell编程,开始了