29 lines
456 B
Bash
Executable File
29 lines
456 B
Bash
Executable File
#!/bin/sh
|
|
|
|
############ CHECK LOG DIRECTORY
|
|
mkdir -p /logs
|
|
chown nginx:www-data /logs
|
|
chmod 0755 /logs
|
|
|
|
############ CONFIGURE LOGROTATE
|
|
LOG_DAYS=${LOG_DAYS:-7}
|
|
|
|
############ START CRON
|
|
crond -b
|
|
cat >/etc/logrotate.d/nginx <<EOF
|
|
/logs/nginx.access.log {
|
|
missingok
|
|
daily
|
|
rotate ${LOG_DAYS}
|
|
compress
|
|
delaycompress
|
|
sharedscripts
|
|
postrotate
|
|
/usr/sbin/nginx -s reopen
|
|
endscript
|
|
}
|
|
EOF
|
|
|
|
############ START
|
|
/usr/sbin/nginx
|