Skip to content

Instantly share code, notes, and snippets.

@ericchen
Last active May 8, 2016 14:44
Show Gist options
  • Save ericchen/76656c621cf25f6e96cc2a616945dea9 to your computer and use it in GitHub Desktop.
Save ericchen/76656c621cf25f6e96cc2a616945dea9 to your computer and use it in GitHub Desktop.
将一个目录下一定时间内的目录移到另外一个目录下

将当前目录下过去30天的目录移动指定目录下

find . -mindepth 1 -type d -mtime +30 | xargs -i mv {} /home/bu/date_30/

1.当前时间24小时—当前时间(昨天-今天)

find . -mtime 0

2.当前时间48小时前–当前时间24小时前(前天-昨天)

find . -mtime 1

4.计算目录大小 du -sh date_90 大小一般控制在10-15G最好

5.压缩并打包

tar -czf date_90.tar.gz date_90/

删除过去100天的目录 find . -type d -ctime +100 | xargs rm -rf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment