Closed vieyahn2017 closed 3 months ago
/etc/logrotate.conf # 主配置文件 /etc/logrotate.d # 配置目录
/etc/logrotate.conf # 主配置文件
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
dateformat -%Y%m%d-%s
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# system-specific logs may be also be configured here.
redis_logrtate.sh
#!/bin/bash
# script redis_logrotate
# Copyright © Huawei Technologies Co., Ltd. 2010-2018. All rights reserved.
set -e
redis_path="/opt/redis"
redis_soft_log_path="${redis_path}/packages/log"
(cat <<EOF
{
copytruncate
size 10M
rotate 5
missingok
compress
notifempty
}
EOF
) > /etc/logrotate.d/redisLog
chmod 600 /etc/logrotate.d/redisLog
sed -i "1i${redis_soft_log_path}/redis-sentinel-login.log" /etc/logrotate.d/redisLog
sed -i "1i${redis_soft_log_path}/redis-login.log" /etc/logrotate.d/redisLog
sed -i "1i${redis_soft_log_path}/redis-sentinel.log" /etc/logrotate.d/redisLog
sed -i "1i${redis_soft_log_path}/redis.log" /etc/logrotate.d/redisLog
/etc/logrotate.d/redisLog
/opt/redis/packages/log/redis.log
/opt/redis/packages/log/redis-sentinel.log
/opt/redis/packages/log/redis-login.log
/opt/redis/packages/log/redis-sentinel-login.log
{
copytruncate
size 10M
rotate 5
missingok
compress
notifempty
}
日志切割之Logrotate https://www.cnblogs.com/clsn/p/8428257.html