#!/bin/bash
#Date:2019-08-30
#58 23 * * * sh /data/scripts/filebeat_log_cut.sh >> /data/logs/cronolog.log 2>&1
. /etc/init.d/functions
Log_Name="filebeat"
Log_Path="/data/filebeat/logs/"
Date=$(date +%Y%m%d)
#备份当日日志
date +"[%F %T] Start"
CMD="cp $Log_Path$Log_Name.log $Log_Path$Log_Name$Date.log"
echo "$CMD"
$CMD
if [ $? == 0 ];then
action "$Log_Path$Log_Name$Date.log 备份成功!"
#生成新日志
> $Log_Path$Log_Name.log
else
action "$Log_Path$Log_Name$Date.log 备份失败!" /bin/false
fi
date +"[%F %T] End"
评论