我如何每天在Linux上旋转任何.log文件 [英] How can I Rotate any .log file on daily basis on linux
本文介绍了我如何每天在Linux上旋转任何.log文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个脚本来每天轮换我的应用程序的日志文件..
像这样..,
I Want to Write a script to rotate log file of my application on the daily basis..
like this..,
#!/bin/ksh
export TERM=xterm
cp -f /data/logs/nohup.log /data/logs/nohup.log.`date +%y%m%d%k%M%S`
> /data/logs/nohup.log
它将在一天结束时自动运行...
which will run automatically at the end of the day...
推荐答案
安装 logrotate [ ^ ]软件包,而不是尝试从头开始重新发明它.
Install the logrotate[^] package instead of trying to reinvent it from scratch.
这篇关于我如何每天在Linux上旋转任何.log文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文