归档日志(让日志以日期结尾)

来源:互联网 发布:东方金信大数据 编辑:程序博客网 时间:2024/05/04 07:03

               今天突然看到jetty日志里面的日志好多是以日期结尾的,但是记得以前学过tar命令,想着具体怎么实现的,就去看了看启动脚本,里面设置了日志的格式,就是将生成的日志又移动为你想要的带日期的格式

eg:你可以在你的目录中创建一个日志文件:touch zy.log

        此时你可以将你的日志文件改成带日期的格式:

mv zy.log zy.log.`date+"%Y-%m-%d-%H:%M"`【显示结果:zy.log.2011-07-13-10:31】

mv zyy.log zyy.log.`date+"%F-%T"`【显示结果:zyy.log.2011-07-13-11:03:46】

(注意:黄色的部分为空格)

  %%   a literal %【最终显示的为一个%】
  %a   locale's abbreviated weekday name (e.g., Sun) 【显示的为周的缩写】
  %A   locale's full weekday name (e.g., Sunday) 【显示的为周的全拼】
  %b   locale's abbreviated month name (e.g., Jan) 【显示月的简写】
  %B   locale's full month name (e.g., January) 【显示月的名字】
  %c   locale's date and time (e.g., Thu Mar  3 23:05:25 2005) 【全部显示,周月日时年】
  %C   century; like %Y, except omit last two digits (e.g., 21) 【世纪】
  %d   day of month (e.g, 01) 【日】
  %D   date; same as %m/%d/%y 【月/日/年】
  %e   day of month, space padded; same as %_d
  %F   full date; same as %Y-%m-%d 【年-月-日】
  %g   last two digits of year of ISO week number (see %G)
  %G   year of ISO week number (see %V); normally useful only with %V
  %h   same as %b
  %H   hour (00..23)  【双位数表示法
  %I   hour (01..12)
  %j   day of year (001..366)
  %k   hour ( 0..23) 【24小时计时法】
  %l   hour ( 1..12) 【12小时计时法】

  %m   month (01..12) 【阿拉伯数字表示法-月】
  %M   minute (00..59) 【分钟】
  %n   a newline 【换行符】
  %N   nanoseconds (000000000..999999999)
  %p   locale's equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S   second (00..60)
  %t   a tab 【tab键】
  %T   time; same as %H:%M:%S  【时间】
  %u   day of week (1..7); 1 is Monday
  %U   week number of year, with Sunday as first day of week (00..53)
  %V   ISO week number, with Monday as first day of week (01..53)
  %w   day of week (0..6); 0 is Sunday
  %W   week number of year, with Monday as first day of week (00..53)
  %x   locale's date representation (e.g., 12/31/99)
  %X   locale's time representation (e.g., 23:13:48)
  %y   last two digits of year (00..99) 【年的后两位数字】
  %Y   year 【年】
  %z   +hhmm numeric timezone (e.g., -0400)
  %:z  +hh:mm numeric timezone (e.g., -04:00)
  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
  %Z   alphabetic time zone abbreviation (e.g., EDT)

原创粉丝点击