#!/bin/bash check_size=150 clean_days=3 int=1 clean_dir=/mnt/shoplog usable=$(df -h | grep /dev/vdb1 | awk '{print $4}') usable=${usable%G*} echo $usable if [ $usable -lt $check_size ];then while(( $int<=$clean_days )) do date=$(date -d "$int day ago" +%Y%m%d) echo $date log_file="$clean_dir/$date-cordispatcher.log" echo $log_file if [ -e $log_file ];then dir="$clean_dir/$date" if [ ! -e $dir ];then mkdir $dir fi mv $clean_dir/$date*.log $clean_dir/$date/ tar zcvf $date.tar.gz ./$date rm -rf $dir fi let "int++" done fi