Nginx log file housekeep/rotation
- put the nginx_log_rotation.sh in some where, e.g. /usr/local/nginx_log_rotation.sh
- add system crontab task(executed every 0 a.m.):
> crontab -e
> 0 0 * * * /bin/sh /usr/local/nginx_log_rotation.sh
> :wq!
Tips:
- Before using it, pls change
nginx_home
,nginx_log_path
andkeep_days
in this script according to your requirement/environment. - Running on CentOS7.4