nginx日志轮巡切割

通过编辑脚本的方式来实现日志每日以及每天的切割纪录。可以通过计划任务的方式实现每天执行脚本,具体情况需要更加实际情况

vim /root/cut_nginx_log.sh

#!bin/sh

Dateformat='date +%Y%m%d'

Basedir="/application/nginx"

Nginxlogdir="$Basedir/logs"

Logname="access_www"

[ -d $Nginxlogdir ]&& cd $Nginxlogdir||exit 1

[ -f ${Logname}.log ]||exit 1

/bin/mv ${Logname}.log ${Dateformat}_${Logname}.log

$Basedir/sbin/nginx -s reload

原文地址:https://www.cnblogs.com/dianzixiaoming/p/6241346.html