Lets take an example, wherein we will find and delete file older than 7 days. We will be using the option “-mtime” of the find command for this. 1. Get a list of files using find command as follows: # find /path_to_directory -mtime +7 -type f -exec ls {}\; 2. If...
如果您输入 +7 ,它将查找超过 7 天的文件。 第三个参数 -exec 允许您传入命令,例如 rm。结束命令需要最后的 {} \;。 来源:http: //www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/ 要删除文件夹,在清空它们内部后,您可以在代码段中 rmdir instad of rm 如果您只想查看...
Examples to Delete Files Older Than X on Linux Here, we'll look at how to delete files in Linux that are more than x days old. Most often, this is used to get rid of backups that are too old or to get rid of rotational logs that are older than a specific number of days. This...
This is a very simple tutorial on how to find, move and delete files older than X days. I needed this for a project where I collected some images and needed to archive and delete them after a while. With this, you will be able with the Linux find command to find your JPG files old...
SUBJECT="WARNING: Apache log files are deleted older than 15 days \$(date)" mail -s "\$SUBJECT" "\$TO" < \$MESSAGE rm \$MESSAGE /tmp/folder.out fi 给delete-old-folders.sh设置可执行权限。 # chmod +x /opt/script/delete-old-folders.sh ...
它于每天早上 7 点运行。 # crontab -e 0 7 * * * /bin/bash /opt/script/delete-old-folders.sh 你将看到类似下面的输出。 Apache Access log files are deleted older than 20 days +---+ Oct 11 /var/log/apache/2daygeek_access.11 Oct 12 /var/log/apache/2daygeek_access.12 Oct 13 ...
# chmod +x /opt//delete-old-files.sh 最后添加一个 cronjob 自动化此任务。它于每天早上 7 点运行。 # crontab -e 0 7 * * * /bin/bash /opt//delete-old-folders.sh 你将看到类似下面的输出。 Apache Access log files are deleted older than 20 days +---+ Oct 11 /var/log/apache/2dayg...
2. Remove Files which are N Days Older To remove files which are 5 days older, use “5d” as timespec. For example, the following command will delete files from the ~/Downloads folder that are not accessed in the last 5 days.
2) Bash Script to Delete a Files Older Than “X” Days in Linux We have a folder named“/var/log/apache/”that contains 15 days of logs and we are going to delete 10 days old files. The articles below are related to this topic, so you may be interested to read. ...
7. 此命令确保RMAN保留每个数据文件的三个备份:RMAN>CONFIGURERETENTIONPOLICYTOREDUNDANCY3; 1. 2. 3. DELETEOBSOLETE 1. 2. 默认情况下,RMAN自动生成控制文件自动备份的名称,并把它们存储在闪回恢复区。以下命令配置RMAN写入控制文件自动备份到/mybackupdir目录:RMAN>CONFIGURECONTROLFILEAUTOBACKUPFORMAT ...