shell日期的应用
1 #!bin/bash 2 3 del_table() 4 { 5 #月初的第一天 6 month_first_day=`date +%Y%m01` 7 8 #要删除的日期 9 last_7day_ago=`date -d "-8day" +%Y%m%d` 10 11 #drop table 12 table='t_focus_goods_coral_month_'$last_7day_ago 13 14 if [[ $month_first_day == $last_7day_ago ]];then 15 exit 0 16 else 17 #mysql -h 1270.0.01 -uxx -pxx -P 3307 -A focus -e "drop table ${table}" 18 echo "${table}" 19 fi 20 } 21 22 del_table