39 lines
952 B
Markdown
39 lines
952 B
Markdown
### 日期和时间
|
||
Linux的时钟分为两种
|
||
|
||
- 系统时钟:由Linux内核通过CPU的工作频率控制
|
||
- 硬件时钟:主板上的时间
|
||
###### date命令
|
||
```shell
|
||
参数:
|
||
-r #显示文件上次修改的时间
|
||
-d #时间转换
|
||
-s #设置时间
|
||
|
||
|
||
date +"%F %T"
|
||
format:输出的时间格式。
|
||
%F 完整的日期;等价于%+4Y-%m-%d
|
||
%Y 年
|
||
%m 月
|
||
%d 日
|
||
%T 时间;等价于%H:%M:%S
|
||
%H 小时
|
||
%M 分钟
|
||
%S 秒
|
||
```
|
||
```shell
|
||
[root@tencentos ~]# clock
|
||
2023-11-26 00:12:24.485439+08:00
|
||
```
|
||
```shell
|
||
Commands:
|
||
status Show current time settings
|
||
show Show properties of systemd-timedated
|
||
set-time TIME Set system time
|
||
set-timezone ZONE Set system time zone
|
||
list-timezones Show known time zones
|
||
set-local-rtc BOOL Control whether RTC is in local time
|
||
set-ntp BOOL Enable or disable network time synchronizatio
|
||
```
|