要删除Linux系统中30天之前的文件,可以按照以下步骤操作。这些步骤包括确定需要清理的文件夹路径、查找30天之前的文件以及删除这些文件。 1. 确定需要清理的文件夹路径 首先,你需要明确哪个文件夹下的文件需要被清理。例如,假设我们要清理/opt/soft/log/目录下的文件。 2. 查找30天之前的文件 使用find命令结合-mtime...
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...
2.1创建shell: touch /opt/soft/bin/auto-del-30-days-ago-log.sh chmod +x auto-del-30-days-ago-log.sh 新建一个可执行文件auto-del-30-days-ago-log.sh,并分配可运行权限 2.2编辑shell脚本: vi auto-del-30-days-ago-log.sh 编辑auto-del-30-days-ago-log.sh文件如下: #!/bin/sh find /opt...
Find files older than X days You can use themtimeparameter to find older files that have not been modified recently. Let's say you want to find files older than 30 days in the current directory. Use this command: find . -mtime +30 Find modified directories in the last n minutes or da...
4. Delete Files Older Than X Days With Specific Extension Rather than erasing everything, you may use many filters to help you find the instructions you need. For instance, you can't get rid of anything edited more than 30 days ago if it has the".log"extension. ...
This article explains how to delete files older or newer than N days, with extra examples like matching only files using a particular extension, and more. For this we'll use find, a command line tool to search for files in a directory.
find $fpath -type f -mtime +15 -exec rm -rf {} \; count=$(cat /tmp/file.out | wc -l) if [ "$prev_count" -lt "$count" ] ; then MESSAGE="/tmp/file1.out" TO="daygeek@gmail.com" echo "Apache Access log files are deleted older than 20 days" >> $MESSAGE ...
Device files are in the /dev directory, and running ls /dev reveals more than a few files in /dev. So how do you work with devices? Linux与其他Unix版本使用相同的设备文件设计。 设备文件位于/dev目录下,运行ls /dev命令可以看到/dev目录下的许多文件。 那么如何操作设备呢? To get started, ...
find dir[ ...] -gid GID find dir[ ...] -user USERNAME find dir[ ...] -group GROUPNAME find dir[ ...] -nouser find dir[ ...] -nogroup -uid UID:列出文件的所有者ID为UID的文件。 -gid GID:列出文件的用户组ID为GID的文件。
命令格式:find pathname -options [-print-exex -ok ...] 命令参数: pathname:查找的目录路径 ~表示home目录 .表示当前目录 /表示根目录 -print:匹配的文件输出到标准输出 -exec:对匹配的文件执行该参数所给出的shell命令 -ok:和-exec作用相同,不过是以一种更安全的模式来执行该参数所给出的shell命令,在执行...