日志切割

logrotate

切割sshd

vim /etc/logrotate.d/sshd 
/var/log/sshd.log {
    missingok
    weekly  每周进行切割
    create 0600 root root  创建文件权限
    minsize 1M  超过1m进行回滚
    rotate 3  副本
}

logrotate -d /etc/logrotate.d/sshd  模拟
logrotate -vf /etc/logrotate.d/sshd  强制进行切割日志服务

切割httpd

yum -y install httpd 
vim /etc/logrotate.d/htttpd
/var/log/httpd/*log {
    daily
    rotate 5 
    sharedscripts
    postrotate
        temp=`ps aux|grep httpd|egrep -v grep|wc -l`
        echo "temp: $temp"
        if [ $temp > 0 ];then
            systemctl restart httpd
        fi
    endscript
}

logrotate -d /etc/logrotate.d/httpd 模拟
logrotate -vf /etc/logrotate.d/httpd 强制进行切割日志服务

推荐阅读更多精彩内容