Date display/Set system time
+ A format displays dates in some format
Format: +%f 2017-08-20 ====== +%y-%m-%d
+%w Show weeks 0 Sunday 1-6 weeks one to Saturday
+%t: minutes: Seconds ====== +%h:%m:%s
-D Displays the date according to your description
-D "1day" after 1 days = = +1day
-D " -1day" 1 days ago
-s time to modify the system
1.1 Commands to modify the system time
ntpdatepool.ntp.org
Ntpdatentp1.aliyun.com
1.2 Use of date
Example 1-1
[Email protected] ~]# date-d " -3day"
Thu Jul 16:32:09 CST 2017
Example 1-2
[Email protected] ~]# date-d "3day"
Wed 216:32:19 CST 2017
Example 1-3
[Email protected] ~]# date-d " -3day" +%f
2017-07-27
Example 1-4
[Email protected] ~]# date-d " -3year" +%f
2014-07-30
Example 1-5
[Email protected] ~]# date-d " -300year" +%f
1717-07-30
[Email protected]~]# # #day
[Email protected]~]# #year Month Day hour min sec
Example 1-6
[Email protected] ~]# date +%t
12:31:54
[Email protected] ~]# date +%h:%m:%s
12:32:1501734744
[Email protected] ~]# date +%h:%m:%s
12:32:28
1.3 # # # #显示十天之前的日期 Format: 2017-07-30_0 year-month-day _ weeks
[[Email protected] ~]# date +%f_%w-d " -10day"
2017-07-24_1
1.4 Setting the time problem
1.4.1 Question 1
[Email protected] ~]# ntpdate pool.ntp.org
Exiting, name server cannot is used:temporary failure in name resolution (-3)
Domain name resolution server (DNS) cannot be used: Domain Name resolution failed
3 12:10:02 ntpdate[3345]: name servercannot be used:temporary failure in name resolution (-3)
1.4.2 Workaround
# # # #1. pingwww.baidu.com
# #报错域名-----Can't change to an IP address
# # # #2. Ping 223.5.5.5
# #排查是否真的是dns的问题
# # # #3. If it is a DNS problem, modify the NIC's configuration file plus
dns1=223.5.5.5
dns2=223.6.6.6
[Email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
# # # #4. Effective
/etc/init.d/network restart
This article is from the "Heyong" blog, make sure to keep this source http://heyong.blog.51cto.com/13121269/1954918
Show/Set system time in Linux