Categories: Tomcat

Tomcat log backup

Jan 25, 2017 2 min.

Following script can be used to archive the log files in tomcat log directory. This script… Archives all the files in logs directory to bkup directory Deletes all the files older than ‘n’ days in bkup directory #!/bin/bash arch_logs() { for file_pattern; do i=1 for log_file in $(find $file_pattern | sort -r); do test $i -eq 1 && ((i=i+1)) && continue; sudo gzip "$log_file" sudo mv *.gz .