无法设置仅仅一年的Linux date命令 [英] Unable to set just year with Linux date command

查看:103
本文介绍了无法设置仅仅一年的Linux date命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,我不能仅用date命令来更新年

For some reason I fail to update year only using date command

date
Tue Mar  4 20:15:42 IST 2014

date '+%Y' -s '2013'

date
Tue Mar  4 20:13:01 IST 2014

我试了两个红帽和Ubuntu ...

I tried it on both RedHat and Ubuntu...

NTP没有运行...

NTP is not running...

推荐答案

显然改变日期,你必须使用完整的设置语法。

Apparently to change the date you have to use the complete setting syntax.

date --set="YYYYmmdd HH:MM"

下面是一个方式来实现你的需求:

Here is a way to achieve your demand :

date --set="$(date +'2013%m%d %H:%M')"

这样你保持月,日,小时,分钟和变革的一年。

This way you maintain month, day, hour and minute and change year.

这篇关于无法设置仅仅一年的Linux date命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆