工作常用shell集合
<1>日志回滚案例======>
[root@localhost test]# cat hbase.sh
hbase_rotate_log ()
{
log=$1;
num=5;
if [ -n "$2" ]; then
num=$2
fi
if [ -f "$log" ]; then # rotate logs
while [ $num -gt 1 ]; do
prev=`expr $num - 1`
[ -f "$log.$prev" ] && mv -f "$log.$prev" "$log.$num"
num=$prev
done
mv -f "$log" "$log.$num";
fi
}
hbase_rotate_log $1
[root@localhost test]# ./hbase.sh install.log
[root@localhost test]# ls
hbase.sh install.log.1 install.out.1