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]