Mtime file content Last modified
The time that the Atime file was read or accessed
CTime File Status Change time
The meaning of Mtime and atime is easy to understand, and ctime needs more explanations. Because the inode maintains the metadata on each file, the Inode data also changes if the file-related metadata changes. This can be caused by a series of actions, including creating symbolic links to files, changing file permissions, or moving files. Because in these cases, the contents of the file are not read or modified, so mtime and atime do not change, but CTime will change.
These time options need to be used in conjunction with a value of n, specified as-n, N, or +n.
Copy the code code as follows:
N * 24
+1 means 1 * 24 + 24 hours away:
+0 means 0 * 24 + 24 hours away
1 means 1 * 24 + 24 to 24.
0 means 0 * 24 + 24 to 0.
-1 means 0 * 24 +24 inside, even for future time ...
1. Current time 24 h-current time (Yesterday-today)
#find. -mtime 0
2. Current time 48 hours ago – Current time 24 hours ago (the day before yesterday)
#find. -mtime 1
3. Current time 48 hours ago (2 days ago)
#find. -mtime +1
4. Current time 24 hours – current time (yesterday-today)
#find. -mtime-1
Examples of commands:
Package the log files within 7 days of the directory.
Find/apps/spark/app/logs-mtime-7-print |xargs tar cjf test.tar.gz
将该目录下7天以内的日志文件进行删除,总是保留最新的。find /apps/spark/app/logs -mtime -7 -print |xargs rm -rf 或者使用exec实现:find /apps/spark/app/logs -mtime -7 -exec rm {} \;
Find files under Linux use Xargs and exec to delete, compress.