一个清除日志的脚本
时间:2009-03-23 来源:sjhf
#!/bin/bash
LOG_DIR=/var/log ROOT_UID=0 LINES=50 E_XCD=66 E_NOTROOT=67 if [ "$UID" -ne "$ROOT_UID" ] then echo "Must be root to run this script." exit $E_NOTROOT fi
if [ -n "$1" ] then lines=$1 else lines=$LINES fi
cd $LOG_DIR
if [ `pwd` != "$LOG_DIR" ] then echo "Can't change to $LOG_DIR." exit $E_XCD fi
tail -$lines messages > mesg.temp mv mesg.temp messages
echo "Logs cleaned up."
exit 0
|
相关阅读 更多 +