Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实现定时删除大量文件 #9

Open
licoded opened this issue Jul 29, 2021 · 0 comments
Open

实现定时删除大量文件 #9

licoded opened this issue Jul 29, 2021 · 0 comments

Comments

@licoded
Copy link
Owner

licoded commented Jul 29, 2021

来自于同学实习中遇到的问题

问题:3TB的日志文件,实现定时清理

  • 难点: 直接 rm -rf dir-name 删除一个文件数很大的文件夹,会占用大量系统资源,造成整个系统的卡顿

方案:设置一个定时任务,删除50天以前的日志文件,运行频率为每天一次

  • 分析: 这样实际上除第一天外,后面每天都只是删除距离当前51天那一天的任务,因为超过51天的文件已经在前一天被删掉了
  • 注意: 但第一天的数据量还是未知的,需要人为干预来确保数据量不会大到让系统崩溃或卡顿。
    建议的做法是在启动该定时任务前手动删除所有日志文件或者至少删除超过50天的日志文件。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant