In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to view the creation time of the file in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
I. brief introduction
The creation time of Linux files depends on the file system type. In earlier file systems before ext4 (ext, ext2, ext3), the file's metadata does not record the file creation time, it only records the access time, modification time, and change time (state change time). The basic information for a typical file is as follows:
[root@bugwz ~] # stat test.file File: 'test.file' Size: 2 Blocks: 8 IO Block: 4096 regular fileDevice: 807h/2055d Inode: 5255117 Links: 1Access: (0755/-rwxr-xr-x) Uid: (0 / root) Gid: (0 / root) Access: 2019-12-12 19purl 1133.175841399 + 0800Modify: 2019-12 19purl 1137.564970487 + 0800Change: 2019-12-12 19Fr11Rich 43.079132663 + 0800 Birth:-
Access: access time, last access time of file data (for example, read file contents)
Modify: the modification time, the last modification time of the file data. (for example, modify the contents of a file)
Change: state change time, which is easily confused with Modify time, the change time of file attributes (permissions, size, etc.)
II. Practice
2.1. Get the creation time of the file
Get the file inode number, as shown below, and get the inode number: 5255117
[root@bugwz data] # stat / data/test.file File:'/ data/test.file' Size: 2 Blocks: 8 IO Block: 4096 regular fileDevice: 807h/2055d Inode: 5255117 Links: 1Access: (0755/-rwxr-xr-x) Uid: (0 / root) Gid: (0 / root) Access: 2019-12-12 19Fran 1133.175841399 + 0800Modify: 2019-12-12 19Jiang 11data/test.file File 37.564970487 + 0800Change: 2019-12-12 19Fr11Rich 43.079132663 + 0800 Birth:-
Find the disk path where the file is located, as shown below, and get the disk path as: / dev/sda7
[root@bugwz data] # df-hFilesystem Size Used Avail Use% Mounted on/dev/sda3 3.9G 2.5G 1.2G 70% / devtmpfs 16G 016G 0% / devtmpfs 16G 0% / dev/shmtmpfs 16G 1.7G 14G 11% / runtmpfs 16G 016G 0% / sys/fs/cgroup/dev/sda1 12G 11G 787M 94% / usr/dev/sda5 7.8G 4.2G 3.2G 57% / tmp/dev/sda7 235G 180G 44G 81% / data/dev/ Sda6 7.8G 2.1G 5.3G 29% / var
Use debugfs to check the creation time of the file, and find that the creation time crtime is: Thu Dec 12 19:05:23 2019
[root@bugwz data1] # debugfs-R 'stat' / dev/sda7debugfs 1.42.9 (28-Dec-2013) Inode: 5255117 Type: regular Mode: 0755 Flags: 0x80000Generation: 758605841 Version: 0x00000000:00000001User: 0 Group: 0 Size: 2File ACL: 0 Directory ACL: 0Links: 1 Blockcount: 8Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x5df2206f:12dddfdc-- Thu Dec 12 19:11:43 2019 atime: 0x5df22065:29ec81dc-Thu Dec 12 19:11:33 2019 mtime: 0x5df22069:86b30fdc-Thu Dec 12 19:11:37 2019crtime: 0x5df21ef3:d586ca44-- Thu Dec 12 19:05:23 2019Size of extra inode fields: 28EXTENTS: (0): 16949121
2.2. Integration script:
#! / bin/sh [$#-ne 1] & & echo "Usage: $0 {FILENAME}" & & exit 1INODE = `ls-I $1 | awk'{print $1} '`FILENAME=$1# if the parameter is passed with /, get the directory path of this parameter and enter the directory `echo $FILENAME | grep / 1 > / dev/ null` & & {FPWD=$ {FILENAME%/*}; FPWD=$ {FPWD:=/}; cd ${FPWD}; FPWD= `pwd` } | | FPWD= `pwd`array = (`pwd`array) (`pwd`array} | sed's array_length=$ @ @ g``) array_length=$ {# array [@]} for ((iTunes ${array_length}; I > = 0transferiMel -) Do unset array [$] SUBPWD= `echo "" ${array [@]} | sed's @ @ / @ g``DISK= `df-h | grep ${SUBPWD} $| awk'{print $1}'`[[- n $DISK]] & & breakdone# file system exits if it is not ext4 [["`df-T | grep ${DISK} | awk'{print $2}`"! = "ext4"] & & {echo ${DISK} is not mount on type ext4! Only ext4 file system support exit 2;} debugfs-R "stat" ${DISK} is all the contents of this article "how to check the creation time of a file in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.