Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Creation time and practical tutorials of getting files under linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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 #

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report