I have over 10.0G logs under /var/log and /var/log/nginx. How can I safely clean it?
7.8G /var/log/nginx/custom 2.0G /var/log/nginx 2.0G /var/log
To control application's lifecycle Unix provides a mechanism called Unix signals. USR1 is custom and usually handles the log rotation, other signal like HUP is standard and performs reload.
http://nginx.org/en/docs/control.html
TERM, INT fast shutdown
QUIT graceful shutdown
HUP changing configuration, keeping up with a changed time zone (only for FreeBSD and Linux), starting new worker processes with a new configuration, graceful shutdown of old worker processes
USR1 re-opening log files
USR2 upgrading an executable file
WINCH graceful shutdown of worker processes
Before send a signal to PID rename the file. After you rename it log entries will still be going into the same file because inode hasn't been changed.
cd /var/log/nginx
mv access.log access.log.old
mv error.log error.log.old
kill -USR1 `cat /var/run/nginx.pid`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With