feat: add nginx log rotation configuration

This commit is contained in:
Konano 2025-07-28 17:37:08 +08:00
parent 05f2644f9b
commit 401c937380
Signed by: Nano
GPG Key ID: 93686B78EE43A65A

View File

@ -470,6 +470,21 @@ configure_node_exporter() {
fi 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() { # configure_nodejs() {
# [ -f /usr/local/bin/node ] && return # [ -f /usr/local/bin/node ] && return
# [ $offline -eq 1 ] && return # [ $offline -eq 1 ] && return
@ -570,3 +585,4 @@ configure_bootinfo
configure_oomkiller configure_oomkiller
# configure_swap # configure_swap
configure_node_exporter configure_node_exporter
configure_nginx_log