linux之logrotate日志切割

2021/12/3 7:09:57

本文主要是介绍linux之logrotate日志切割,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

案例:

定制配置文件/etc/logrotate.d/java

/home/admin/server_home/facereg/*.log{
daily
su root root
rotate 30
copytruncate
nodelaycompress
compress
ifempty
missingok
create 0700 admin admin
dateext
dateformat .%Y-%m-%d-%H-%s
olddir /home/admin/server_home/facereg
}
#######################################
/home/admin/server_home/facereg/logs/*.log{
daily
su root root
rotate 30
copytruncate
nodelaycompress
compress
ifempty
missingok
create 0700 admin admin
dateext
dateformat .%Y-%m-%d-%H-%s
olddir /home/admin/server_home/facereg
}

/etc/logrotate.d/redis

/home/admin/cluster/redis/log/*.log{
daily
su root root
rotate 30
copytruncate
nodelaycompress
compress
ifempty
missingok
create 0700 admin admin
dateext
dateformat .%Y-%m-%d-%H-%s
olddir /home/admin/cluster/redis/log
}

 

定制定时任务

00 00 * * * /usr/bin/logrotate -v -f /etc/logrotate.d/java
00 00 * * * /usr/bin/logrotate -v -f /etc/logrotate.d/redis

效果如下:

 



这篇关于linux之logrotate日志切割的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程