2019-03-12 15:34:39 2769瀏覽
今天扣丁學堂Linux培訓老師給大家介紹一下關于監(jiān)控Linux服務器活動的命令,首先watch、top和ac命令為我們監(jiān)視Linux服務器上的活動提供了一些十分高效的途徑。為了在獲取系統(tǒng)活動時更加輕松,Linux系統(tǒng)提供了一系列相關的命令。在這篇文章中,我們就一起來看看這些對我們很有幫助的命令吧。
Every 5.0s: date butterfly: Wed Jan 23 15:59:14 2019 Wed Jan 23 15:59:14 EST 2019
$ watch -n 10 who Every 10.0s: who butterfly: Tue Jan 23 16:02:03 2019 shs :0 2019-01-23 09:45 (:0) dory pts/0 2019-01-23 15:50 (192.168.0.5) nemo pts/1 2019-01-23 16:01 (192.168.0.15) shark pts/3 2019-01-23 11:11 (192.168.0.27)
$ watch uptime Every 2.0s: uptime butterfly: Tue Jan 23 16:25:48 2019 16:25:48 up 22 days, 4:38, 3 users, load average: 1.15, 0.89, 1.02
$ watch -n 5 'ps -ef | wc -l' Every 5.0s: ps -ef | wc -l butterfly: Tue Jan 23 16:11:54 2019 245
$ watch -n 5 free -m Every 5.0s: free -m butterfly: Tue Jan 23 16:34:09 2019 Every 5.0s: free -m butterfly: Tue Jan 23 16:34:09 2019 total used free shared buff/cache available Mem: 5959 776 3276 12 1906 4878 Swap: 2047 0 2047
$ top -u nemo top - 16:14:33 up 2 days, 4:27, 3 users, load average: 0.00, 0.01, 0.02 Tasks: 199 total, 1 running, 198 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 5959.4 total, 3277.3 free, 776.4 used, 1905.8 buff/cache MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 4878.4 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 23026 nemo 20 0 46340 7820 6504 S 0.0 0.1 0:00.05 systemd 23033 nemo 20 0 149660 3140 72 S 0.0 0.1 0:00.00 (sd-pam) 23125 nemo 20 0 63396 5100 4092 S 0.0 0.1 0:00.00 sshd 23128 nemo 20 0 16836 5636 4284 S 0.0 0.1 0:00.03 zsh
$ ac total 1261.72
$ ac -p shark 5.24 nemo 5.52 shs 1251.00 total 1261.76
$ ac -d | tail -10 Jan 11 total 0.05 Jan 12 total 1.36 Jan 13 total 16.39 Jan 15 total 55.33 Jan 16 total 38.02 Jan 17 total 28.51 Jan 19 total 48.66 Jan 20 total 1.37 Jan 22 total 23.48 Today total 9.83
【關注微信公眾號獲取更多學習資料】