linux文件的時間格式


背景:

今天觀察數據庫文件的時候發現:

ls -la *.ibd
-rw-rw---- 1 mysql dba        98304 Sep 25  2012 a.ibd                
-rw-rw---- 1 mysql dba       131072 Oct 12  2012 b.ibd -rw-rw---- 1 mysql dba        98304 Oct 17 15:34 c.ibd                              
-rw-rw---- 1 mysql dba        98304 Jan  4 13:33 d.ibd

$stat a.ibd
  File: `a.ibd'
  Size: 98304         Blocks: 192        IO Block: 4096   regular file
Device: 811h/2065d    Inode: 134743266   Links: 1
Access: (0660/-rw-rw----)  Uid: (  502/   mysql)   Gid: (  501/     dba)
Access: 2012-09-25 18:35:15.037849294 +0800
Modify: 2012-09-25 19:20:02.820634436 +0800
Change: 2012-09-25 19:20:02.820634436 +0800

$stat b.ibd
  File: `b.ibd'
  Size: 8246001664    Blocks: 16105488   IO Block: 4096   regular file
Device: 811h/2065d    Inode: 95945504    Links: 1
Access: (0660/-rw-rw----)  Uid: (  502/   mysql)   Gid: (  501/     dba)
Access: 2012-10-30 23:24:39.473915516 +0800
Modify: 2012-11-01 05:06:35.091416693 +0800
Change: 2012-11-01 05:06:35.091416693 +0800

$stat c.ibd  
  File: `c.ibd'
  Size: 98304         Blocks: 192        IO Block: 4096   regular file
Device: 811h/2065d    Inode: 22544608    Links: 1
Access: (0660/-rw-rw----)  Uid: (  502/   mysql)   Gid: (  501/     dba)
Access: 2012-06-14 04:10:26.114518581 +0800
Modify: 2012-10-17 15:34:47.824547168 +0800
Change: 2012-10-17 15:34:47.824547168 +0800

$stat d.ibd
  File: `d.ibd'
  Size: 98304         Blocks: 192        IO Block: 4096   regular file
Device: 811h/2065d    Inode: 125304910   Links: 1
Access: (0660/-rw-rw----)  Uid: (  502/   mysql)   Gid: (  501/     dba)
Access: 2012-08-20 14:04:33.844796019 +0800
Modify: 2013-01-04 13:33:59.944597727 +0800
Change: 2013-01-04 13:33:59.944597727 +0800

        

到這里不知道你發現沒有,為什么同樣是2012年的表文件,為什么ls -la和stat看到的信息卻是不一樣的?為什么同樣是2012年的文件,為什么有的標注2012年,為什么有的沒有標注?

答案:

Linux下,默認如果在6個月之內的"新"文件都是以:"Oct 17 15:34"顯示,不帶年份,如果超過6個月的"老文件"以:“Mar 30 2012”帶年份顯示;我們可以添加‘--time-style=style’選型修改查看文件的顯示方式具體格式有:

+format

如: --time-style="+%Y-%m-%d %H:%M:%S" 展示的時候就是 ‘2002-03-30 23:45:56’。

ls -l --time-style="+%Y-%m-%d %H:%M:%S"

2013-03-13 00:02:50

full-iso

 

如:ls -l --time-style="+%Y-%m-%d %H:%M:%S.%N %z" 

2013-03-13 00:02:50.000000000 +0800

long-iso

這種格式和ls -l --time-style='+%Y-%m-%d %H:%M'輸出的效果是一樣的,到分鍾級別

2013-03-13 00:02

iso

ls -l --time-style="+%Y-%m-%d $newline%m-%d %H:%M"

ls -l --time-style="iso"

locale

等同於:ls -l --time-style="+%b %e  %Y$newline%b %e %H:%M"

posix-style

 

像這種輸出格式Mar 30 2002’ and ‘Mar 30 23:45’ 或 ‘2002-03-30 23:45

文件有3個時間,

last access time: ls -lu filename

last modified time:ls -lm filename

last change to inode information (metadata):ls -lc filename


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM