Bash Script to Compress / Transfer / Remove Log Files
- by Jason
I am currently using chronolog to set log file names for Apache with date. They are in the following format:
/WEB/LOGS/APACHE_ACCESS_YYYY-MM-DD.log
/WEB/LOGS/APACHE_ERROR_YYYY-MM-DD.log
I would like to have a script that runs on the first of every month and compresses the log files from the previous month, transfers them to another host (via SCP) and then deletes the compressed file.
find . -name '*.log' -mtime +1 -type f
I've found several examples like the one above that allow you to select files x days old, but I need all files from the previous month. I am the first to admit my bash scripting skills are weak so would really appreciate any help and guidance.