我在一个服务器系统上工作,不允许我存储超过50千兆字节的文件.我的应用程序需要20分钟才能生成文件.有什么方法可以将所有超过30分钟的文件从源移动到目的地吗?我试过rsync:
rsync -avP source/folder/ user@destiantionIp:dest/folder
最佳答案
你可以使用find和-exec来实现这个目的: –
原文链接:https://www.f2er.com/linux/440340.html根据需要将/ sourcedirectory和/ destination / directory /替换为源路径和目标路径.
find /sourcedirectory -maxdepth 1 -mmin -30 -type f -exec mv "{}" /destination/directory/ \;
基本上该命令的作用是,它试图在当前文件夹-maxdepth 1中查找30分钟前最后修改的文件-mmin -30并将它们移动到指定的目标目录.如果要使用上次访问文件的时间,请使用-amin -30.
或者,如果要查找在某个范围内修改的文件,可以使用-mmin 30 -mmin -35之类的内容,这样可以获得修改时间超过30但不到35分钟的文件.
手册页中的参考文献: –
-amin n
File was last accessed n minutes ago.
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed,any fractional part is ignored,so to match -atime
+1,a file has to have been accessed at least two days ago.
-mmin n
File's data was last modified n minutes ago.
-mtime n
File's data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.