原文链接
数据库时间久了,难免会产生很多日志,Deepgreen的日志与Greenplum一样,都存在pg_log文件夹下,我们可以使用以下脚本,配合Linux定时任务,保存固定日期的日志即可:
#!/bin/bash
# filename: gp_clear.sh
# start time
start_time=$(date)
echo "-------- Start time is $start_time --------" start_seconds=$(date +%s) # delete log files #find /data/gpmaster/gpseg-1/pg_log -mtime +15 -name "*.csv" -exec rm -rf {} \; find /seg0/gpseg0/pg_log -mtime +15 -name "*.csv" -exec rm -rf {} \; #find /seg1/gpseg1/pg_log -mtime +90 -name "*.csv" -exec rm -rf {} \; #find /seg2/gpseg2/pg_log -mtime +90 -name "*.csv" -exec rm -rf {} \; #find /seg3/gpseg3/pg_log -mtime +90 -name "*.csv" -exec rm -rf {} \; # end time end_time=$(date) echo "-------- End time is $end_time --------" end_seconds=$(date +%s) diff=$((end_seconds - start_seconds)) echo "Total $diff seconds." echo "" echo ""
执行方法,修改+15为需要保留日志的日期数,+15代表保留15天:
./gp_clear.sh
原文链接