Jay*_*n T 2 scripting linux redhat shell
可能的重复:
删除超过 30 天的文件的脚本
我的硬盘突然满了,我四处寻找,直到我终于发现隐藏在Library/Logs/Console/myname/中的“console.log.9”文件是112 Gigs!
我无法打开并正确检查它。
我做了一些研究,并找到了使用 find 和 exec 命令从特定路径查找和删除超过 30 天的日志文件的方法。
find /export/home/ftp ( -name console.log -or -name server.log ) -mtime +30 -exec rm -f {} +
但我想每天轮换 console.log 并且是否有任何 shell 脚本可以每天轮换 console.log。
请帮我解决这个问题。
将文件添加到/etc/logrotate.d
,包含类似
/export/home/ftp/console.log {
rotate 7
daily
compress
missingok
notifempty
}
Run Code Online (Sandbox Code Playgroud)