From aeefe2e895f3627cb0a17dae432c8c379ba46ab7 Mon Sep 17 00:00:00 2001 From: Konano Date: Mon, 28 Jul 2025 17:28:21 +0800 Subject: [PATCH] feat: add nginx log rotation configuration --- configure_priv.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/configure_priv.sh b/configure_priv.sh index 65d72cb..2c052bd 100755 --- a/configure_priv.sh +++ b/configure_priv.sh @@ -462,6 +462,21 @@ configure_node_exporter() { fi } +configure_nginx_log() { + [ $offline -eq 1 ] && return + [ "$(uname)" = "Darwin" ] && return + ! command_exists nginx && return + [ ! -f /etc/logrotate.d/nginx ] && return + [ -z "$(grep 'daily' /etc/logrotate.d/nginx)" ] && return + + if confirm_action "要配置 nginx 日志轮转修改为每周吗?" "N"; then + # 修改 /etc/logrotate.d/nginx 文件,替换 daily 为 weekly + sudo sed -i 's/daily/weekly/' /etc/logrotate.d/nginx + # 重新加载 logrotate 配置 + sudo logrotate -f /etc/logrotate.d/nginx + fi +} + # configure_nodejs() { # [ -f /usr/local/bin/node ] && return # [ $offline -eq 1 ] && return @@ -562,3 +577,4 @@ configure_bootinfo configure_oomkiller # configure_swap configure_node_exporter +configure_nginx_log