#!/bin/bash
#Date:
#Author:
#Description: This scripts function is automatic Zip And Delete File and Log N days ago
#Version:1.1
export LANG=en_US.UTF-8
time2=$(date "+%Y%m%d")
#获取文件位置
ipfile_url="/home/crawler/output_data/chapter_action_${time2}/ipoklist.txt"
successfile_url="/home/crawler/output_data/chapter_action_${time2}/successchapterlist.log"
novisitorfile_url="/home/crawler/output_data/chapter_action_${time2}/novisitor.txt"
ipfilesize=1
successfilesize=1
novisitorfilesize=1
#判断文件是否存在
if [ -f $ipfile_url ] && [ -f $successfile_url ] && [ -f $novisitorfile_url ]
then
#获取文件大小(单位kb)
ipfilesize=$((`ls -l ${ipfile_url} | awk '{ print $5 }'`))
successfilesize=$((`ls -l ${successfile_url} | awk '{ print $5 }'`))
novisitorfilesize=$((`ls -l ${novisitorfile_url} | awk '{ print $5 }'`))
maxsize=$((1*10))
if [ $ipfilesize -lt $maxsize ] && [ $successfilesize -lt $maxsize ] && [ $novisitorfilesize -lt $maxsize ]
then
echo "*******服务器的章节负结算文件输出为空 " | mail -s “=?UTF-8?B?`echo 章节负结算mvisitor-chapter.jar运行异常 | base64`?=” *******@139.com 135*******39@139.com
else
echo "200.200.7.166服务器的章节负结算文件输出有内容 " | mail -s “=?UTF-8?B?`echo 章节负结算mvisitor-chapter.jar运行正常 | base64`?=” 150*******77@139.com 135*******39@139.com
fi
else
echo "file not exist"
echo "2*******6服务器的章节负结算没有文件输出 " | mail -s “=?UTF-8?B?`echo 章节负结算mvisitor-chapter.jar运行异常 | base64`?=” 150*******77@139.com 135*******39@139.com
fi
创建定时任务使用crontab
crontab -e #编辑
crontab -l 查看我们的设置