查找 -mtime 早于 1 小时的文件 [英] find -mtime files older than 1 hour
问题描述
我现在每 24 小时运行一次这个命令.
find/var/www/html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" -exec rm -f {} ;
我想每 1 小时运行一次并删除早于 1 小时的文件.这是否正确:
find/var/www/html/audio -daystart -maxdepth 1 -mtime **+0.04** -type f -name "*.mp3" -exec rm -f {} ;
我不确定我使用的是十进制数吗??
感谢您的任何更正.
编辑
或者我可以只使用 -mmin 60 吗?这是正确的吗?
EDIT2
我试过你的测试,好在你建议了.我得到一个空的结果.我希望删除 OLDER 超过 60 分钟的所有文件!我怎样才能做到这一点??我的命令真的这样做了吗?
-mmin
怎么样?
find/var/www/html/audio -daystart -maxdepth 1 -mmin +59 -type f -name "*.mp3" -exec rm -f {} ;
来自男人的发现:
<前>-分钟文件的数据在 n 分钟前最后一次修改.另外,请务必先对此进行测试!
<前>... -exec echo rm -f '{}' ;^^^^ 添加 'echo' 这样您就可以看到将要获取的命令运行而不是先实际尝试它们.I have this command that I run every 24 hours currently.
find /var/www/html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" -exec rm -f {} ;
I would like to run it every 1 hour and delete files that are older than 1 hour. Is this correct:
find /var/www/html/audio -daystart -maxdepth 1 -mtime **+0.04** -type f -name "*.mp3" -exec rm -f {} ;
I am not sure of my use of the decimal number??
Thanks for any corrections.
EDIT
OR could I just use -mmin 60? Is this correct?
EDIT2
I tried your test, good thing you suggested it. I got an empty result. I want all files OLDER than 60mins to be deleted! How can I do this?? Does my command actually do this?
What about -mmin
?
find /var/www/html/audio -daystart -maxdepth 1 -mmin +59 -type f -name "*.mp3"
-exec rm -f {} ;
From man find:
-mmin n File's data was last modified n minutes ago.
Also, make sure to test this first!
... -exec echo rm -f '{}' ; ^^^^ Add the 'echo' so you just see the commands that are going to get run instead of actual trying them first.
这篇关于查找 -mtime 早于 1 小时的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!