选项:
-d #自定义日期
-s #修改日期 时间
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
#显示系统时间 [root@qls ~]# date Wed Jul 29 11:19:19 CST 2020 [root@qls ~]# date +%Y #世纪 2020 [root@qls ~]# date +%y #年代 20 [root@qls ~]# date +%m #月份 07 [root@qls ~]# date +%d #日期 29 [root@qls ~]# date +%Y-%m-%d 2020-07-29 [root@qls ~]# date +%F #显示日期 2020-07-29 [root@qls ~]# date +%y-%m-%d 20-07-29 [root@qls ~]# date +%H #时 11 [root@qls ~]# date +%M #分 23 [root@qls ~]# date +%S #秒 24 [root@qls ~]# date Wed Jul 29 11:23:28 CST 2020 [root@qls ~]# date +%H:%M:%S 11:23:43 [root@qls ~]# date +%T #显示时间 11:24:08 [root@qls ~]# date +%F-%T 2020-07-29-11:24:34 [root@qls ~]# date +%w #周几 3 [root@qls ~]# date +%W #今年第几周 30 [root@qls ~]# date +%s #距离1970年1月1日0分0秒过来多少秒 1595993167 [root@qls ~]# date +%F 2020-07-29 [root@qls ~]# date -d "-1 day" +%F 2020-07-28 [root@qls ~]# date -d "+1 day" +%F 2020-07-30 [root@qls ~]# date -d "+1 month" +%F 2020-08-29 [root@qls ~]# date -d "-1 month" +%F 2020-06-29 [root@qls ~]# date -d "-1 year" +%F 2019-07-29 [root@qls ~]# date -d "+1 year" +%F 2021-07-29 [root@qls ~]# date Wed Jul 29 11:31:42 CST 2020 [root@qls ~]# date -s 20200730 Thu Jul 30 00:00:00 CST 2020 [root@qls ~]# date Thu Jul 30 00:00:08 CST 2020 [root@qls ~]# date -s 2020/07/29 Wed Jul 29 00:00:00 CST 2020 [root@qls ~]# date Wed Jul 29 00:00:02 CST 2020 [root@qls ~]# date -s 11:32:30 Wed Jul 29 11:32:30 CST 2020 [root@qls ~]# date Wed Jul 29 11:32:31 CST 2020 [root@qls ~]# date -s "20200730 11:00:00" Thu Jul 30 11:00:00 CST 2020 #时间同步 ntpdate [root@qls ~]# yum install ntpdate -y 向时间服务器进行同步时间 ntp.aliyun.com ntp1.aliyun.com .... ntp7.aliyun.com [root@qls ~]# ntpdate ntp.aliyun.com 29 Jul 11:36:33 ntpdate[31370]: step time server 203.107.6.88 offset -84415.000442 sec [root@qls ~]# date Wed Jul 29 11:36:35 CST 2020 [root@qls ~]# date -s 20200730 Thu Jul 30 00:00:00 CST 2020 [root@qls ~]# ntpdate ntp.aliyun.com 29 Jul 11:36:56 ntpdate[31392]: step time server 203.107.6.88 offset -44591.413933 sec [root@qls ~]# date Wed Jul 29 11:37:02 CST 2020 |