Script to move and compress theĀ postgres logs
It is one of the maintenance activity in postgres , once you moved your logs means you will get some more free space at data partition .simple logic is postgres logs is inside the data directory. following script will be helpful to move postgres logs to some other partition .
1.This script used for moving and compressingĀ older than 30 days log files:
vi /home/postgres/eds/tarlog.sh find /data/emut16_slavedata/pg_log/ -mtime +30 | xargs tar -czvPf /pg_xlog/older_log.tar.gz vi /home/postgres/eds/removelogs.sh find /data/emut16_slavedata/pg_log/ -type f -name "*.log" -mtime +30 -exec rm {} \; but before that get a listing to see what you are about to delete and tar find /data/emut16_slavedata/pg_log/ -type f -name "*.log" -mtime +30 -exec ls -tr {} \;
2.This script used for moving and compressingĀ older than 30 minutes and hoursĀ log files:
vi /home/postgres/eds/tarlog.sh find /data/emut16_slavedata/pg_log/ -cmin +30 | xargs tar -czvPf /pg_xlog/older_log.tar.gz vi /home/postgres/eds/removelogs.sh find /data/emut16_slavedata/pg_log/ -type f -name "*.log" -cmin +30 -exec rm {} \; but before that get a listing to see what you are about to delete and tar find /data/emut16_slavedata/pg_log/ -type f -name "*.log" -cmin +30 -exec ls -tr {} \;
If you want to give 3 hours mention likeĀ -cmin+180