#!/bin/sh
if [ $# -lt 2 ]; then
        echo "Usage:  run_log_clear.sh [start month before] [end month before]"
        echo "        start month >= 6 at least"
        echo "        end month > start month"
        echo "Sample: run_log_clear.sh 6 12 "
        echo "        (Clear log before now 6 to 12 month)"
        exit 0;
else
        if [ "$2" -lt "$1" ]
        then
                echo "Usage:  run_log_clear.sh [start month before] [end month before]"
                echo "        start month >= 6 at least"
                echo "        end month > start month"
                exit 0
        fi

        for idx in $(seq $1 $2)
        do
                now=$(( `date +%s`-(($idx*30)*86400)))
                target=`date -D '%s' +%Y.%m -d "$now"`
                echo $target
                `/bin/rm -f /Storage/SystemLog/[$target\]*`
                `/bin/rm -f /Storage/OCPP/[$target\]*`
		`/bin/rm -f /Storage/OCPP_PH/[$target\]*`
        done

fi