我在不允许存储超过50 GB的文件的服务器系统上工作。我的应用程序需要20分钟才能生成文件。有什么方法可以将超过30分钟的所有文件从源移动到目标?我试过了rsync
:
rsync -avP source/folder/ user@destiantionIp:dest/folder
但这不会从我的服务器中删除文件,因此存储限制失败。
其次,如果我使用该mv
命令,仍在生成的文件也将移至目标文件夹,并且程序将失败。
您可以find
与-exec
此一起使用:-
根据需要替换/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.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句