跳转至

logrotate

# /etc/logrotate.d/applog
/opt/logs/*.log 
/opt/logs/*/*.log 
/opt/logs/*/*/*.log 
{
  size 20M
  rotate 3
  missingok
  notifempty
}

# 手工执行
sudo logrotate /etc/logrotate.d/applog --force --verbose

# 常用参数
# Truncate the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one.
copytruncate

参考文献

作者: aisuhua