移动文件30分钟之前 [英] Move files that are 30 minutes old

查看:129
本文介绍了移动文件30分钟之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器系统,这并不让我来存储文件超过50千兆字节的工作。我的应用程序需要20分钟生成一个文件。有什么办法,由此我可以将所有那些超过30分钟的老从源到目的地的文件吗?我试图的rsync

I work on a server system that does not allow me to store files more than 50 gigabytes. My application takes 20 minutes to generate a file. Is there any way whereby I can move all the files that are more than 30 minutes old from source to destination? I tried rsync:

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

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

but this does not remove the files from my server and hence the storage limit fails.

其次,如果我用 MV 命令,仍在如何产生也将文件移动到目标文件夹和程序失败。

Secondly, if I use the mv command, the files that are still getting generated also move to the destination folder and the program fails.

推荐答案

您可以使用找到 -exec 本: -

You can use find along with -exec for this:-

替换 / sourcedirectory /目的/目录/ 用,因为你需要的源和目标路径。

Replace /sourcedirectory and /destination/directory/ with the source and target paths as you need.

find /sourcedirectory -maxdepth 1 -mmin -30 -type f -exec mv "{}" /destination/directory/ \;

基本命令的作用是什么,它​​试图找到在当前文件夹 -maxdepth 1 这是最后一次修改30分钟前 -mmin文件-30 ,并将其移动到指定的目标目录。如果你想使用的时间上次访问文件使用 -amin -30

What basically the command does is, it tries to find files in the current folder -maxdepth 1 that were last modified 30 mins ago -mmin -30 and move them to the target directory specified. If you want to use the time the file was last accessed use -amin -30.

或者,如果你想找到你可以使用类似 -mmin的范围内修改过的文件30 -mmin -35 这将让你修改的30多个文件,但不到35分钟前。

Or if you want to find files modified within a range you can use something like -mmin 30 -mmin -35 which will get you the files modified more than 30 but less than 35 minutes ago.

人参考页: -

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

这篇关于移动文件30分钟之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆