通过date命令可直接现在的时间戳
# date +%s
1265851947
# date +%s
1265851947
也可以得到指定时间的时间戳
# date -d "2007-07-30 9:30" +%s
1185759000
# date -d "2007-07-30 9:30" +%s
1185759000
然后我们可以将它们转换为系统的时间格式
# date -d '1970-01-01 UTC 1265851947 sec' +"%F %T"
2010-02-11 09:32:27
# date -d '1970-01-01 UTC 1265851947 sec' +"%F %T"
2010-02-11 09:32:27
# date -d '1970-01-01 UTC 1185759000 sec' +"%F %T"
2007-07-30 09:30:00
2007-07-30 09:30:00
For example, open /etc/ntp.conf file using vi text editor:
Locate server parameter and set it as follows:
# vi /etc/ntp.conf
Locate server parameter and set it as follows:
server pool.ntp.org
Save the file and restart the ntpd service:
# /etc/init.d/ntpd start
You can synchronize the system clock to an NTP server immediately with following command:
# ntpdate pool.ntp.org
没有评论:
发表评论