Monday 10 April 2017

simple bash 'logrotate'

'logrotate' = not a logrotate but more of a multiple result handle
e.g. test results, core files, log files

'infinate' (max bash integer) 'logrotate' pattern for bash:


    # multiple runs of same test, . . logrotate test result
    [[ -e dir/testresult_${testname}_${host}.xml ]] && {
        K=$(find dir/testresult_${testname}_*_${host}.xml 2>/dev/null |wc -l)
        ((K++))
        mv dir/testresult_${testname}_{,${K}_}${host}.xml
    }

Coupled with test harvest e.g. . . 
rsync -avzh --remove-source-files ${user}@${host}:XML/*${host}.xml ./ || true

optional || true so that lack of xml files doesn't mark job/script as fail