我在/ var / log和/ var / log / nginx下有超过10.0G的日志。我该如何安全地清洁它?
7.8G / var / log / nginx / custom 2.0G / var / log / nginx 2.0G / var / log
答案 0 :(得分:3)
控制应用程序的生命周期Unix提供了一种称为Unix信号的机制。 USR1是自定义的,通常处理日志旋转,其他信号如HUP是标准的并执行重新加载。
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
在向PID发送信号之前,重命名该文件。重命名后,日志条目仍将进入同一文件,因为inode尚未更改。
cd /var/log/nginx
mv access.log access.log.old
mv error.log error.log.old
kill -USR1 `cat /var/run/nginx.pid`