移动30分钟的文件

我在一个服务器系统上工作,不允许我存储超过50千兆字节的文件。 我的应用程序需要20分钟来生成一个文件。 有什么办法可以将所有超过30分钟的文件从源文件移动到目标文件? 我试过rsync

 rsync -avP source/folder/ user@destiantionIp:dest/folder 

但是这不会从我的服务器中删除文件,因此存储限制失败。

其次,如果使用mv命令,仍然生成的文件也会移动到目标文件夹,程序将失败。

你可以和-exec一起使用find

用你需要的源路径和目标路径替换/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分钟前。

man页中的参考资料: –

  -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.