Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com

This Blog is protected by DMCA.com

huuphan.com. Powered by Blogger.

Log file zimbra script

The function read /var/log/zimbra.log use bash script.




To input
1. FILE1=/var/log/zimbra.log
2. FOLDER=/tmp/test
2. NUMBER=/tmp/test/number.txt file

To output
TEMP_LOG=$FOLDER/tmp_zimbra.log

Function f_check_folder to check folder existing yes or no.
f_check_folder () {
        if [[ -d $FOLDER ]]; then
                if [[ ! -s $NUMBER ]]; then
                        touch $NUMBER
                        echo 0 > $NUMBER
                fi
        else
                mkdir -p $FOLDER
                touch $NUMBER
                echo 0 > $NUMBER
        fi
}

Function f_get_log read /var/log/zimbra.log file
f_get_log () {
        NUM=`cat $NUMBER`
        SUM=`expr "$NUM" + 1`
        tail -n +"$SUM" $FILE1 > $TEMP_LOG
        echo `wc -l < $FILE1` > $NUMBER
}

Log file zimbra script

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com