Debugging - Log Rotation

> Code - (Programming|Computer) Language > Code - Debugging (Bug)

1 - About

log Rotation

Advertising

3 - Log File Rotation

3.1 - Bash

# First Parameter is the log file
# Second parameter is the log number
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
}

3.2 - logrotate

code/debugging/log_rotation.txt · Last modified: 2018/11/12 09:38 by gerardnico