Get the App
SLTechnology News&Howtos  ›  Servers  › 

Creation time and practical tutorials of getting files under linux

Shulou Source: shulou.com Published: 2022-06-02 04:13:13 10月23日 Update

Background

Sometimes we need to get the creation time of the file.

For example:

When I was studying the "xtrabackup schematic", I wanted to make sure that xtrabackup_log was the earliest created and the last saved file. We need to know the creation timestamp and modification timestamp of the xtrabackup_logfile file.

Review: Linux's three timestamps about files

The file system of Linux has three timestamps, which can be obtained by viewing the file information using the stat instruction. They are ATime, MTime and CTime.

[root@192-168199198 backups] # stat 2.txt File: '2.txt' Size: 16 Blocks: 8 IO Block: 4096 regular fileDevice: 821h/2081d Inode: 15 Links: 1Access: (0644) Uid: (0 / root) Gid: (0 / root) Access: 2019-07-23 12 Vutrix 12 rides 14.276981038 + 0800Modify: 2019-07-23 12 rides 12 rides 41.415980158 + 0800Change: 2019-07-23 12 rides 41.415980158 + 0800 Birth:-

ATime-the most recent access time of the file

As soon as the file is read, the ATime is updated, corresponding to the value of Access obtained by the stat command.

[root@192-168,199,198 backups] # cat 2.txt # / tmp/1.txtfor I in `cat / tmp/ 1.txt`do {echo-n $I ""; statx $I 2 > / dev/null | grep crtime | awk'{print $7}';} > > / tmp/2.txtdonecat / tmp/2.txt | sort-K2 | output below less### is # #. / ibdata1 23:32:59./xtrabackup_logfile 23:32:59 # / tmp/1.txt > / tmp/2.txtfind. -type f > / tmp/1.txtfor I in `cat / tmp/ 1.txt`do {echo-n $I ""; statx $I 2 > / dev/null | grep mtime | awk'{print $7}' } > > / tmp/2.txtdonecat / tmp/2.txt | sort-K2 | the output below less### is #. / ibdata1 23:33:00./mysql/engine_cost.ibd 23:33:00./mysql/gtid_executed.ibd 23:33:00./mysql/help_category.ibd 23:33:00./mysql/help_keyword.ibd 23:33:00./mysql/help_relation.ibd 23:33:00./mysql/help_topic.ibd 23 sort 33 : 00./mysql/innodb_index_stats.ibd 23:33:00./mysql/innodb_table_stats.ibd 23:33:00./mysql/plugin.ibd 23:33:00..../xtrabackup_logfile 23:33:09 #

Tags: File time system support content principle method directory three command backup script path change update actual combat parameter attribute tool time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information MySQL Shulou Technology Apple