Linux中查看系统时间
程序员文章站
2022-04-29 19:54:12
...
1、系统时间
在Linux中有硬件时钟与系统时钟两种时钟。硬件时钟是指主机板上的时钟设备,也就是通常可在BIOS画面设定的时钟。系统时钟则是指kernel中的时钟。所有Linux相关指令与函数都是读取系统时钟的设定。因为存在两种不同的时钟,那么它们之间就会存在差异。当Linux启动时,系统时钟会去读取硬件时钟的设定,之后系统时钟即独立运作。
2、查看系统时间方法
1)date命令
[[email protected]_0_11_centos ~]# date
Tue Dec 24 00:08:05 CST 2019
[[email protected]_0_11_centos ~]#
2)uptime
[[email protected]_0_11_centos ~]# uptime
00:08:39 up 2 days, 1:53, 3 users, load average: 0.05, 0.09, 0.06
[[email protected]_0_11_centos ~]#
3)w
查看当前用户所做的事情,结合了uptime whoami ps -ef 命令
[[email protected]_0_11_centos ~]# w
00:09:18 up 2 days, 1:54, 3 users, load average: 0.03, 0.08, 0.06
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
root pts/1 161.117.188.158 23:48 6.00s 0.02s 0.00s w
root pts/2 :20 Sat22 2days 0.01s 0.01s bash
root pts/3 161.117.188.158 23:48 20:59 1.19s 1.18s top
[[email protected]_0_11_centos ~]#
[[email protected]_0_11_centos ~]# uptime
00:10:59 up 2 days, 1:56, 3 users, load average: 0.12, 0.09, 0.06
[[email protected]_0_11_centos ~]# whoami
root
[[email protected]_0_11_centos ~]# ps
PID TTY TIME CMD
1470 pts/1 00:00:00 ps
12612 pts/1 00:00:00 bash
[[email protected]_0_11_centos ~]#
4)top
top - 00:12:49 up 2 days, 1:58, 3 users, load average: 0.02, 0.06, 0.05
Tasks: 93 total, 1 running, 92 sleeping, 0 stopped, 0 zombie
%Cpu0 : 2.7 us, 2.7 sy, 0.0 ni, 94.3 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st
KiB Mem : 1916008 total, 68104 free, 297728 used, 1550176 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 1430104 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
639 kube 20 0 221284 31408 5344 S 0.7 1.6 9:59.23 kube-scheduler
2251 root 20 0 463936 45252 8696 S 0.7 2.4 20:34.72 kubelet
401 root 20 0 47668 9940 9576 S 0.3 0.5 15:00.00 systemd-journal
1080 root 20 0 710164 10040 7704 S 0.3 0.5 5:08.72 rsyslogd
3600 root 20 0 609148 11112 1980 S 0.3 0.6 9:07.19 barad_agent
1 root 20 0 43528 3764 2512 S 0.0 0.2 0:13.10 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:22.44 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:49.05 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 0:00.63 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
15 root 20 0 0 0 0 S 0.0 0.0 0:00.03 khungtaskd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
5)who
[[email protected]_0_11_centos ~]# who
root pts/1 2019-12-23 23:48 (161.117.188.158)
root pts/2 2019-12-21 22:32 (:20)
root pts/3 2019-12-23 23:48 (161.117.188.158)
6)last
列出最近登录过系统的用户
[[email protected]_0_11_centos ~]# last
root pts/3 161.117.188.158 Mon Dec 23 23:48 still logged in
root pts/1 161.117.188.158 Mon Dec 23 23:48 still logged in
root pts/2 :20 Sat Dec 21 22:32 still logged in
root pts/1 47.74.209.185 Sat Dec 21 22:32 - 02:32 (03:59)
root pts/0 47.74.209.185 Sat Dec 21 22:32 - 02:32 (03:59)
reboot system boot 3.10.0-957.21.3. Sat Dec 21 22:14 - 00:14 (2+02:00)
root pts/2 :20 Sat Dec 21 22:08 - 22:14 (00:05)
root pts/1 47.74.209.185 Sat Dec 21 21:55 - crash (00:19)
root pts/0 47.74.209.185 Sat Dec 21 21:55 - crash (00:19)
root pts/1 47.74.188.153 Sat Dec 21 21:35 - 21:52 (00:17)
root pts/0 47.74.188.153 Sat Dec 21 21:35 - 21:52 (00:17)
root pts/1 47.74.188.153 Sat Dec 21 17:02 - 18:44 (01:41)
上一篇: js循环的总结
下一篇: Linux inode