Sam*_*cke 10
如果您只需要每个月删除旧的 server.log 和 console.log,您也可以使用logrotate最有可能已经在 RHEL 下运行的。像这样的配置片段将在/etc/logrotate.d/*.conf配置文件位于系统上的任何位置或任何位置工作。
# rotate server.log and console.log every month
# delete, not compress, old file
/export/home/ftp/server.log /export/home/ftp/console.log {
monthly
rotate 0
}
Run Code Online (Sandbox Code Playgroud)
如上所述,自定义的每月 cron 也可以很好地工作。事实上,由于 logrotate 是从 cron 运行的,您可以将其视为各种 cron 扩展。哈。
假设您确实需要使用find以通过子目录递归:
find /export/home/ftp \( -name console.log -or -name server.log \) -mtime +30 -exec rm -f {} +
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7408 次 |
| 最近记录: |