date新的使用方法

日志文件很多,查找时候很麻烦,有个命令能查询当天的日志,方便!!!

下面是我的日志文件所在位置:

[root@244835 logs]# ll

total 9516

-rw-r--r-- 1 root root 583891 Sep 9 23:59 access_log.20110909

-rw-r--r-- 1 root root 556134 Sep 10 23:59 access_log.20110910

-rw-r--r-- 1 root root  538526 Sep 11 23:58 access_log.20110911

-rw-r--r-- 1 root root 432825 Sep 12 23:59 access_log.20110912

-rw-r--r-- 1 root root 596363 Sep 13 23:59 access_log.20110913

-rw-r--r-- 1 root root 589573 Sep 14 23:59 access_log.20110914

-rw-r--r-- 1 root root  796052 Sep 15 23:59 access_log.20110915

-rw-r--r-- 1 root root 667158 Sep 16 23:59 access_log.20110916

-rw-r--r-- 1 root root 569773 Sep 17 23:59 access_log.20110917

-rw-r--r-- 1 root root 992825 Sep 18 23:59 access_log.20110918

-rw-r--r-- 1 root root 1208195 Sep 19 21:22 access_log.20110919

-rw-r--r-- 1 root root 169960 Sep 9 23:59 error_20110909.log

-rw-r--r-- 1 root root 110970 Sep 10 23:59 error_20110910.log

-rw-r--r-- 1 root root   96004 Sep 11 23:58 error_20110911.log

-rw-r--r-- 1 root root 139869 Sep 12 23:59 error_20110912.log

-rw-r--r-- 1 root root 145121 Sep 13 23:59 error_20110913.log

-rw-r--r-- 1 root root 190224 Sep 14 23:59 error_20110914.log

-rw-r--r-- 1 root root 253909 Sep 15 23:59 error_20110915.log

-rw-r--r-- 1 root root 278949 Sep 16 23:59 error_20110916.log

-rw-r--r-- 1 root root 219677 Sep 17 23:59 error_20110917.log

-rw-r--r-- 1 root root 295857 Sep 18 23:59 error_20110918.log

-rw-r--r-- 1 root root 178874 Sep 19 21:22 error_20110919.log

很多的,查找时候也很不方便,下面有我新发现的查找方法:

Access_log的:

 

[root@244835 logs]# ll | grep access_log.$(date +%Y%m%d)

-rw-r--r-- 1 root root 1238384 Sep 19 21:23 access_log.20110919

这样就能查到当天的日志

Error的

[root@244835 logs]# ll | grep error_$(date +%Y%m%d).log

-rw-r--r-- 1 root root 181780 Sep 19 21:23 error_20110919.log

好不好,谁用谁知道,O(∩_∩)O~!


你可能感兴趣的:(Date)