zhouer 发表于 2018-8-28 12:36:21

shell 执行ftp的动作和日志合并

#!/bin/bash  
date=` date +%Y%m%d`
  
yue=` date +%Y%m`
  
one=/opt/zzx/coutlogs/1/$yue
  
two=/opt/zzx/coutlogs/2/$yue
  
NewLog=/opt/zzx/count
  
logs=zzx.log-$date
  
if[ ! -d "$one" ]||[ ! -d "$two" ] ; then
  
mkdir -p "$one" "$two"
  
else
  
if [ ! -f "$one/$logs.gz" ]||[ ! -f "$two/$logs.gz" ] ; then
  
ftp -n $two/$logs
  
touch /opt/zzx/count/zzx.log-$date
  
for log in zzx.log-$date
  
do
  
    sort -m -t " " -k 4 -o$NewLog/$log $one/$log $two/$log
  
done
  
fi
  
fi
  
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.zzxtbl.top.com
  
rm -f $NewLog/bj.log-$date
  
rm -f $one/bj.log-$date
  
rm -f $two/bj.log-$date
  

  

  
计划任务crontab -e 5点:00执行
  
vi /etc/crontab
  
0 5 * * * * root /opt/ftpmput.sh


页: [1]
查看完整版本: shell 执行ftp的动作和日志合并