案例:
定制配置文件/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
效果如下: