40

Linux下修改系统时间的简单方法

 5 years ago
source link: https://www.linuxprobe.com/linux-simple-2.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
导读 Linux下怎么一步到位设置系统时间。拿linux虚拟机做实验的朋友会知道。当你把linux还原到某个点的时候,vmware帮不了你把系统时间也给重设了。所以这时候就要手工来搞。关于怎么设Linux时间。网上介绍也很多,但是都是抄来抄去的东西。那怎么才能高效快捷的设置系统时间呢?

开始的时候,或者网上都有的说法,比如说把时间设为2014-07-12 18:30:50。

我们会先设日期

   date -s 20140712

再设时间

date -s 18:30:50

一台机器还好说,多了你就会烦了。有没有一步到位的办法呢?几经搜索发现有!

date 071218302014(月日时分年)

这样可以一步到位。但是!但是什么呢,对于Linux来说,这样的写法太不human,太难记了。有没有更简单的方法?几经摸索,发现,有!

date -s "20140712 18:30:50"

这样就可以一步到位,而又容易记忆了。偷着用了好长时间了,一般儿人我不告诉他,虚。

时间设置完了就要保存了。如果你会正常关机还好说。系统关的时候会保存一次,可是如果你可能不正常关机的话,可以这么先保存一下设置

hwclock --systohc

对的,是这么写。网上大多的写法是

clock -w

或者

hwclock -w

而你仔细分析下就知道,clockhwclock的软链接。而hwclockhelpman里根本未提-w这个参数。不知道-w是哪年的写法。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK