This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
operation-and-maintenance-a…/bigdata-scripts_test3/roles/zookeeper/files/zklogdelete.sh
2020-03-10 19:52:21 +08:00

21 lines
552 B
Bash
Executable File

#!/bin/sh
#只保留最近三天的日志,如需要多保留几天修改最后 -n days
#将此脚本加载到系统定时任务中 /etc/crontab
#脚本会读取环境变量,固需要配置环境变量。
#. /etc/profile
day=$(date +"%Y-%m-%d" -d "-3 days")
zk=`jps | grep QuorumPeerMain | wc -l`
if [[ $zk = "1" ]];then
#echo $ZOOKEEPER_HOME/logs/system/*.$day*
rm -rf $ZOOKEEPER_HOME/logs/system/*.$day*
fi
kafka=`jps | grep Kafka | wc -l`
if [[ $kafka = "1" ]];then
#echo $KAFKA_HOME/logs/*.$day*
rm -rf $KAFKA_HOME/logs/*.$day*
fi