美文网首页
cron + logrotate 日志切割

cron + logrotate 日志切割

作者: 明明就_c565 | 来源:发表于2024-03-18 16:06 被阅读0次

cron配置

vim /etc/cron.hourly/logrotate

#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.d/cmp

EXITVALUE=$?

if [ $EXITVALUE != 0 ]; then

    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"

fi

exit 0

logrotate配置

/etc/logrotate.d/cmp

/var/log/app/*/*.log {

    su root root

    daily

    rotate 180

    size 50M

    compress

    delaycompress

    missingok

    notifempty

    dateext

    dateformat -%Y%m%d.%s

}

crontab服务

启动

systemctl status crond

systemctl start crond

systemctl ebable crond

相关文章

  • Nginx目录

    Nginx日志轮转,用于logrotate服务的日志切割 /etc/logrotate.d/nginx Nginx...

  • logrotate切割nginx日志

    首先安装logrotate日志切割工具 yum -y install logrotate vim /etc/log...

  • linux日志切割工具 logrotate

    1、介绍 Logrotate是linux日志切割工具 Logrotate是基于crontab定时任务实现的定时日志...

  • 高效的log工具:Logrotate

    Logrotate的介绍 显而易见,Logrotate是基于CRON来运行的,其脚本是「/etc/cron.dai...

  • nginx日志文件切割

    使用脚本对nginx日志文件进行按天切割 然后配置crontab进行每天切割使用 使用logrotate对ngin...

  • 日志切割

    《Linux使用logrotate来切割日志文件》 https://www.jb51.net/article/11...

  • 日志切割

    logrotate 切割sshd 切割httpd

  • linux 日志管理服务 logrotate

    logrotate 是操作系统用来管理日志的工具,支持日志的切割、压缩、清理以及邮件报警等,通过 crontab ...

  • 日志轮转之logrotate

    用linux自带的logrotate对进行容器中的nginx日志轮转,发现切割后日志依然往以前的日志中写,后...

  • Tomcat日志切割(logrotate)

    logrotate是个强大的系统软件,它对日志文件有着一套完整的操作模式,譬如:转储、邮件和压缩等,并且默认log...

网友评论

      本文标题:cron + logrotate 日志切割

      本文链接:https://www.haomeiwen.com/subject/fvqzzdtx.html