Back

如何处理服务器上的大日志文件(how to deal with huge log file in production environment?)

发布时间: 2014-01-22 01:24:00

答案:使用 echo. 不要使用 rm  (short answer:  use 'echo' but not 'rm' )

$ echo '' > huge_file.log  

原因:  运行中的系统,会有一个process一直在写入这个日志文件。如果简单的删掉的话,磁盘空间不会释放。除非把这个process也干掉。 而使用echo 的话,会把这个文件的内容清空,非常安全有效。 可以做到空间的实时释放(每秒大约1G)   ( explaination:  the huge log file is always written by some PROCESS. The disk space is not freed if we simplely remove this huge file until the PROCESS is terminated. However, the echo command will clear the file's content and free the disk space in real-time. (about 1G/s ) )

refer to : http://stackoverflow.com/questions/332629/rm-not-freeing-diskspace   and thanks to :  jiejie, our Operation Master! 

Back