Unable to set just year with Linux date command [closed]

 ̄綄美尐妖づ 提交于 2019-12-08 09:35:17

问题


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

I tried it on both RedHat and Ubuntu...

NTP is not running...


回答1:


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.



来源:https://stackoverflow.com/questions/22168639/unable-to-set-just-year-with-linux-date-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!