mkdir -p /home/code/databack/data
touch /home/code/databack/data/20240205.zip
touch /home/code/databack/data/20240203.zip
touch /home/code/databack/data/20240206.zip
touch /home/code/databack/data/20240207.zip
touch /home/code/databack/data/20240208.zip
touch /home/code/databack/data/20240608.zip
touch /home/code/databack/data/20240708.zip
touch /home/code/databack/data/20240908.zip
mkdir -p /home/code/databack/data/20240216
mkdir -p /home/code/databack/data/20240218
mkdir -p /home/code/databack/data/20240219
mkdir -p /home/code/databack/data/20240619
mkdir -p /home/code/databack/data/20240719
mkdir -p /home/code/databack/data_his
touch /home/code/databack/data_his/20240205.zip
touch /home/code/databack/data_his/20240203.zip
touch /home/code/databack/data_his/20240206.zip
touch /home/code/databack/data_his/20240207.zip
touch /home/code/databack/data_his/20240208.zip
touch /home/code/databack/data_his/20240608.zip
touch /home/code/databack/data_his/20240708.zip
touch /home/code/databack/data_his/20240908.zip
mkdir -p /home/code/databack/data_his/20240216
mkdir -p /home/code/databack/data_his/20240218
mkdir -p /home/code/databack/data_his/20240219
mkdir -p /home/code/databack/data_his/20240619
mkdir -p /home/code/databack/data_his/20240719
mkdir -p /home/code/databack/data_agzx
agzx_fi=nb1
fi_ip=232
bdate=`date -d "15 days ago" +"%Y%m%d"`
clean_logs="/home/code/a.log"
clean_func(){
path=$1
ls -1|grep -v zip|grep ^20|awk '{print $1}'|while read folder_name
do
if [ "$folder_name" -le "$bdate" ];then
mv ${folder_name} ${folder_name}_${agzx_fi}_${fi_ip}
echo "于`date +"%Y-%m-%d %H:%M:%S"`:将${folder_name}文件名称修改为${folder_name}_${agzx_fi}_${fi_ip}。" >> ${clean_logs}
echo "于`date +"%Y-%m-%d %H:%M:%S"`:${folder_name}_${agzx_fi}_${fi_ip}文件开始压缩..."
zip -r -1 ${folder_name}_${agzx_fi}_${fi_ip}.zip ${folder_name}_${agzx_fi}_${fi_ip}
echo "于`date +"%Y-%m-%d %H:%M:%S"`:${folder_name}_${agzx_fi}_${fi_ip}文件完成压缩,名称为:${folder_name}_${agzx_fi}_${fi_ip}.zip" >> ${clean_logs}
chmod 777 ${folder_name}_${agzx_fi}_${fi_ip}.zip
rm -r ${path}${folder_name}_${agzx_fi}_${fi_ip}
echo "于`date +"%Y-%m-%d %H:%M:%S"`:将${path}${folder_name}_${agzx_fi}_${fi_ip}文件删除。" >> ${clean_logs}
mv ${folder_name}_${agzx_fi}_${fi_ip}.zip /home/code/databack/data_agzx
echo "于`date +"%Y-%m-%d %H:%M:%S"`:将${folder_name}_${agzx_fi}_${fi_ip}.zip文件转移至/home/code/databack/data_agzx目录" >> ${clean_logs}
fi
done
}