[原创]touch事项两则_VMware, Unix及操作系统讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  VMware, Unix及操作系统讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2811 | 回复: 0   主题: [原创]touch事项两则        下一篇 
wulcan
版主
等级:中校
经验:1795
发帖:124
精华:0
注册:2014-3-19
状态:离线
发送短消息息给wulcan 加好友    发送短消息息给wulcan 发消息
发表于: IP:您无权察看 2014-10-13 9:05:37 | [全部帖] [楼主帖] 楼主

1、FreeBSD下的touch,多了一个-d功能。

最近频繁使用touch,习惯于用-d参数来为文件指定一个时间,但是偶尔在老机器上操作,却发现报错,提示没有这个参数,感觉到非常奇怪。仔细man了一下,才发现FreeBSD10.0以前的版本中没有这个参数,只有-t参数。

-d和-t功能一样,只是输入日期和时间的格式不一样,另外就是-d参数多了两个选项,一个是比秒更小的单位,可以是分秒或毫秒等;另一个是tz选项,指示使用utc的时间:

-d Change the access and modification times to the specified time instead of the current time of day. The argument is of the form ``YYYY-MM-DDThh:mm:SS[.frac][tz]'' where the letters represent the following:
YYYY The year.
MM The month of the year, from 01 to 12.
DD The day of the month, from 01 to 31.
T The letter T or a space.
hh The hour of the day, from 00 to 23.
mm The minute of the hour, from 00 to 59.
SS The second of the minute, from 00 to 61.
.frac An optional fraction, consisting of a period or a comma followed by one or more digits. The number of significant digits depends on the kernel config-uration and the filesystem, and may be zero.
tz An optional letter Z indicating the time is in UTC. Otherwise, the time is assumed to be in local time.
-t Change the access and modification times to the specified time instead of the current time of day. The argument is of the form ``[[CC]YY]MMDDhhmm[.SS]'' where each pair of letters represents the following:
CC The first two digits of the year (the century).
YY The second two digits of the year. If ``YY'' is
specified, but ``CC'' is not, a value for `YY'' between 69 and 99 results in a ``CC'' value of 19.
Otherwise, a ``CC'' value of 20 is used.
MM The month of the year, from 01 to 12.
DD the day of the month, from 01 to 31.
hh The hour of the day, from 00 to 23.
mm The minute of the hour, from 00 to 59.
SS The second of the minute, from 00 to 61.


另外Linux版的touch还比bsd版的touch少了-A参数和-h参数。

-A参数指定一个时间差值,正值为向后,负值为向前:

# stat test.php
1336615508 349608 -rwxr-xr-x 1 root www 4294967295 65 "Oct 13 08:41:21 2014" "Oct 10 16:52:35 2014" "Oct 10 16:52:35 2014" "May 25 15:57:12 2014" 4096 8 0x800 test.php
# touch -A 085059 test.php
# stat test.php
1336615508 349608 -rwxr-xr-x 1 root www 4294967295 65 "Oct 13 17:32:20 2014" "Oct 11 01:43:34 2014" "Oct 13 08:42:18 2014" "May 25 15:57:12 2014" 4096 8 0x800 test.php


 -h比较简单,就是在遇到链接的时候,只更改链接本身的时间,不改变链接所指向的文件。

2、touch参数的SS,也就是秒的值最大是可以到61的,按正常理解,应该到59就可以了,为什么还有60和61呢?

简单百度一下:闰秒,就可以了解答案:

    闰秒,又称“跳秒”,是为了协调地球自转速度不均匀造成的世界时和精确原子时之间的差异,而将标准时刻增加或减少1秒,常称正闰秒或负闰秒,时间一般在年底或年中(也可能在季末)

具体的解释,比较复杂,需要读者去慢慢研读。

该贴由hui.chen转至本版2014-11-5 17:04:53




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论