我在/ var / log和/ var / log / nginx下有超过10.0G的日志。如何安全清洁?
7.8G / var / log / nginx / custom 2.0G / var / log / nginx 2.0G / var / log
为了控制应用程序的生命周期,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
Run Code Online (Sandbox Code Playgroud)
在向 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`
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5931 次 |
| 最近记录: |