大网数据广告活动
服务器运维问答

delete millions of folders and files efficiently

· 52CE 我爱测

I have a server with a huge file system that is used for continues writes and reads without hiccups and needs to be active at all times. My goal is to have a cronjob that deletes empty folders and files based on name and older th…

问题原文

原帖链接 · Shovals · CC BY-SA 4.0

I have a server with a huge file system that is used for continues writes and reads without hiccups and needs to be active at all times.

My goal is to have a cronjob that deletes empty folders and files based on name and older than X amount of days. The obvious answer is to use find -name -mtime -delete but it uses too much disk resources and causing IO wait and other programs to miss their checks because of server unresponsiveness.

Is there any easy to use tool that does this kind of work? maybe limit disk usage? something else i haven't thought of?

社区高分解答

原帖链接 · HBruijn · CC BY-SA 4.0

Use ionice to reduce the priority of your find command and minimize the impact on other applications.

ionice -c 3 find -name -mtime -delete

-c 3 is class "idle" and a program running with idle io priority will only get disk time when no other program has asked for disk IO (for a defined grace period). The impact of idle IO processes on normal system activity should be zero.

If that never happens (likely on a system that sees use 24x7) try for instance -c 2 -n 7 for the lowest best-effort priority

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-05-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。