LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1247|回复: 2

用`date`取到了错误的时间,谁知道是什么原因?

[复制链接]
发表于 2008-11-7 13:33:46 | 显示全部楼层 |阅读模式
在某脚本里,用`date`写日志,计时如下:

timeA=`date '+%s'`
  command
timeB=`date '+%s'`
echo cost:"`expr $timeB - $timeA`":seconds"
Time=`date '+%Y%m%d%H%M%S.%N'`

得到的日志有一段,如下××区域,时间突然跑到了2010年。
非常奇怪:

--------------------------------------------------------------------------------
command1,finish:step30899:20081105230206.619119000
command1:cost:2:seconds
command2,start:30899:20081105230206.621046000
command2,finish:step30899:20081105230206.683681000
command2:cost:0:seconds
command3,start:30900:20081105230206.687282000
command3,finish:step30900:20081105230206.854253000
command3:cost:0:seconds
command1,start:30900:20081105230206.856630000
command1,finish:step30900:20081105230208.455166000
command1:cost:2:seconds
command2,start:30900:20081105230208.457564000
command2,finish:step30900:20081105230208.519492000
command2:cost:0:seconds
5w:cost:175:seconds
command4,start:30900:20081105230208.526216000
×××××××××××××××××××××××××××××××
command4,finish:step30900:20101216151740.741785000
command4:cost:66586532:seconds
All:finished:20101216151740.789967000
......

command1,start:30911:20101216152853.182240000
command1,finish:step30911:20101216152931.658863000
command1:cost:38:seconds
command2,start:30911:20101216152931.660822000
command2,finish:step30911:20101216152931.722282000
command2:cost:0:seconds
command3,start:30912:20101216152931.725722000
command3,finish:step30912:20101216152931.919971000
command3:cost:0:seconds
command4,start:30912:20101216152931.922329000
command4,finish:step30912:20101216152931.989285000
command4:cost:0:seconds
command1,start:30912:20101216152931.991576000
×××××××××××××××××××××××××
command1,finish:step30912:20081105234714.831425000
command1:cost:-66584537:seconds
command2,start:30912:20081105234714.833691000
command2,finish:step30912:20081105234714.896784000
command2:cost:0:seconds
command3,start:30913:20081105234714.900092000
command3,finish:step30913:20081105234715.060197000
command3:cost:1:seconds
command4,start:30913:20081105234715.062475000
command4,finish:step30913:20081105234715.131603000
command4:cost:0:seconds
command1,start:30913:20081105234715.133916000
command1,finish:step30913:20081105234753.810726000
command1:cost:38:seconds
command2,start:30913:20081105234753.812993000
command2,finish:step30913:20081105234753.874139000
command2:cost:0:seconds
--------------------------------------------------------------------------------
发表于 2008-11-18 18:36:13 | 显示全部楼层
这个应该不是shell造成的吧,有人改系统时间了?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-1-4 13:20:07 | 显示全部楼层
脚本是自动运行的,除非是有其它程序改了时间。

  怎样查呢?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表