1、显示统计占用系统内存最多的进程,并排序。
方法一
[root@test ~]#ps aux --sort=%mem
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S Sep20 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Sep20 0:18 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< Sep20 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S Sep20 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S Sep20 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? R Sep20 7:21 [rcu_sched]
root 10 0.0 0.0 0 0 ? S< Sep20 0:00 [lru-add-drain]
root 11 0.0 0.0 0 0 ? S Sep20 0:18 [watchdog/0]
root 13 0.0 0.0 0 0 ? S Sep20 0:00 [kdevtmpfs]
root 14 0.0 0.0 0 0 ? S< Sep20 0:00 [netns]
root 15 0.0 0.0 0 0 ? S Sep20 0:01 [khungtaskd]
root 16 0.0 0.0 0 0 ? S< Sep20 0:00 [writeback]
root 17 0.0 0.0 0 0 ? S< Sep20 0:00 [kintegrityd]
root 18 0.0 0.0 0 0 ? S< Sep20 0:00 [bioset]
root 19 0.0 0.0 0 0 ? S< Sep20 0:00 [bioset]
root 20 0.0 0.0 0 0 ? S< Sep20 0:00 [bioset]
root 21 0.0 0.0 0 0 ? S< Sep20 0:00 [kblockd]
root 22 0.0 0.0 0 0 ? S< Sep20 0:00 [md]
root 23 0.0 0.0 0 0 ? S< Sep20 0:00 [edac-poller]
root 24 0.0 0.0 0 0 ? S< Sep20 0:00 [watchdogd]
root 30 0.0 0.0 0 0 ? S Sep20 0:01 [kswapd0]
root 31 0.0 0.0 0 0 ? SN Sep20 0:00 [ksmd]
root 32 0.0 0.0 0 0 ? SN Sep20 0:08 [khugepaged]
root 33 0.0 0.0 0 0 ? S< Sep20 0:00 [crypto]
root 41 0.0 0.0 0 0 ? S< Sep20 0:00 [kthrotld]
root 43 0.0 0.0 0 0 ? S< Sep20 0:00 [kmpath_rdacd]
root 44 0.0 0.0 0 0 ? S< Sep20 0:00 [kaluad]
root 45 0.0 0.0 0 0 ? S< Sep20 0:00 [kpsmoused]
root 46 0.0 0.0 0 0 ? S< Sep20 0:00 [ipv6_addrconf]
root 59 0.0 0.0 0 0 ? S< Sep20 0:00 [deferwq]
root 90 0.0 0.0 0 0 ? S Sep20 0:00 [kauditd]
root 244 0.0 0.0 0 0 ? S< Sep20 0:00 [ata_sff]
root 260 0.0 0.0 0 0 ? S Sep20 0:00 [scsi_eh_0]
root 261 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_tmf_0]
root 262 0.0 0.0 0 0 ? S Sep20 0:00 [scsi_eh_1]
root 263 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_tmf_1]
root 266 0.0 0.0 0 0 ? S< Sep20 0:00 [ttm_swap]
root 274 0.0 0.0 0 0 ? S< Sep20 0:16 [kworker/0:1H]
root 283 0.0 0.0 0 0 ? S Sep20 0:30 [jbd2/vda1-8]
root 284 0.0 0.0 0 0 ? S< Sep20 0:00 [ext4-rsv-conver]
root 485 0.0 0.0 0 0 ? S< Sep20 0:00 [nfit]
root 2858 0.0 0.0 0 0 ? S Nov01 0:02 [kworker/u2:1]
root 6330 0.0 0.0 0 0 ? S Oct31 0:12 [kworker/u2:2]
root 10504 0.0 0.0 0 0 ? R 14:28 0:00 [kworker/0:1]
root 29972 0.0 0.0 0 0 ? S Nov20 0:00 [kworker/0:2]
root 531 0.0 0.0 110104 860 tty1 Ss+ Sep20 0:00 /sbin/agetty --noclear tty1 linux
root 530 0.0 0.0 110104 876 ttyS0 Ss+ Sep20 0:00 /sbin/agetty --keep-baud 115200,38400,9600 ttyS0 vt220
root 525 0.0 0.0 25904 956 ? Ss Sep20 0:00 /usr/sbin/atd -f
root 490 0.0 0.0 55520 1104 ? S<sl Sep20 0:05 /sbin/auditd
root 12552 0.0 0.0 127768 1412 ? Ss Nov05 0:00 SCREEN -S jupyerhub
root 12341 0.0 0.0 127900 1496 ? Ss Nov05 0:00 SCREEN -A jupyterhub
root 14271 0.0 0.0 99980 1600 ? Sl Oct31 0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2021 -container-ip 172.17.0.2 -container-port
root 14251 0.0 0.0 99980 1604 ? Sl Oct31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8888 -container-ip 172.17.0.2 -container-port
root 14261 0.0 0.0 99980 1604 ? Sl Oct31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2031 -container-ip 172.17.0.2 -container-port
root 527 0.0 0.0 126288 1624 ? Ss Sep20 0:09 /usr/sbin/crond -n
root 14290 0.0 0.0 18364 1644 pts/2 Ss+ Oct31 0:00 /bin/bash /etc/gaga.sh
root 519 0.0 0.0 26376 1744 ? Ss Sep20 0:15 /usr/lib/systemd/systemd-logind
root 874 0.0 0.0 115436 1768 ? S Sep20 0:00 /bin/sh /application/mysql-5.6.42/bin/mysqld_safe --datadir=/application/mysql-5.6.42/data --pid-file=/app
chrony 537 0.0 0.0 117784 1876 ? S Sep20 0:15 /usr/sbin/chronyd
root 14275 0.0 0.1 264004 1900 ? Sl Oct31 0:01 docker-containerd-shim b06a869d21137a3dddbb60335a8adc23aaa1066c718ffc3439e65ade04e1e766 /var/run/docker/li
root 608 0.0 0.1 155496 1924 pts/0 R+ 22:04 0:00 ps aux --sort=%mem
root 752 0.0 0.1 107464 2156 ? Ss Sep20 0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H qiuping
root 374 0.0 0.1 45012 2196 ? Ss Sep20 0:00 /usr/lib/systemd/systemd-udevd
root 905 0.0 0.1 125116 2272 ? Ss Nov02 0:00 nginx: master process /usr/sbin/nginx
dbus 513 0.0 0.1 58220 2292 ? Ss Sep20 0:28 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
33 14402 0.0 0.1 33428 2432 pts/2 S Oct31 0:03 nginx: worker process
root 12553 0.0 0.1 116388 3004 pts/4 Ss+ Nov05 0:00 /bin/bash
root 14395 0.0 0.1 32720 3184 pts/2 S Oct31 0:00 nginx: master process /usr/sbin/nginx -g daemon off;
root 820 0.0 0.1 41072 3220 ? Ssl Sep20 37:17 /usr/sbin/aliyun-service
root 548 0.1 0.1 116628 3244 pts/0 Ss 22:04 0:00 -bash
jupyter 12639 0.0 0.1 116840 3404 pts/5 Ss+ Nov05 0:00 /bin/bash -l
root 14397 0.0 0.1 237312 3468 pts/2 Sl Oct31 0:01 /usr/bin/duckchat-gateway-ubuntu -httpBackend=http://127.0.0.1/ 1>/dev/null
root 1 0.0 0.1 125460 3584 ? Ss Sep20 11:12 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
nginx 906 0.0 0.2 125888 4052 ? S Nov02 0:03 nginx: worker process
root 12512 0.0 0.2 32528 4228 ? S<sl Nov19 1:35 /usr/local/aegis/aegis_update/AliYunDunUpdate
root 1125 0.0 0.2 112864 4340 ? Ss Sep20 0:00 /usr/sbin/sshd -D
root 534 0.1 0.3 157388 5984 ? Ss 22:04 0:00 sshd: root@pts/0
root 821 0.0 0.3 362012 6508 ? Ssl Sep20 3:44 /usr/sbin/rsyslogd -n
root 1113 0.0 0.4 242200 9324 ? Ssl Sep20 46:15 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --st
65534 28829 0.0 0.5 439336 9536 pts/2 S Nov21 0:00 php-fpm: pool www
root 351 0.0 0.5 47328 9628 ? Ss Sep20 0:15 /usr/lib/systemd/systemd-journald
65534 1944 0.0 0.5 439532 10600 pts/2 S Nov19 0:00 php-fpm: pool www
65534 18283 0.0 0.5 439532 10604 pts/2 S Nov19 0:00 php-fpm: pool www
65534 30518 0.0 0.5 439532 10612 pts/2 S Nov17 0:00 php-fpm: pool www
polkitd 521 0.0 0.6 716592 11452 ? Ssl Sep20 0:11 /usr/lib/polkit-1/polkitd --no-debug
65534 4633 0.0 0.6 439532 12620 pts/2 S Nov19 0:00 php-fpm: pool www
65534 13194 0.0 0.6 439676 12644 pts/2 S Nov18 0:00 php-fpm: pool www
65534 8699 0.0 0.6 439704 13088 pts/2 S Nov16 0:00 php-fpm: pool www
root 815 0.0 0.7 573920 14744 ? Ssl Sep20 9:33 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
root 12586 1.5 0.8 132912 15116 ? S<sl Nov19 78:05 /usr/local/aegis/aegis_client/aegis_10_75/AliYunDun
root 14396 0.0 0.9 438808 16952 pts/2 S Oct31 1:29 php-fpm: master process (https://tech.souyunku.com/etc/php/7.2/fpm/php-fpm.conf)
root 14391 0.0 0.9 54812 16956 pts/2 S+ Oct31 6:54 /usr/bin/python /usr/bin/supervisord --nodaemon --configuration /etc/supervisor/supervisord.conf
root 1460 0.0 1.2 613004 24204 ? Ssl Sep20 0:27 PM2 v3.5.1: God Daemon (https://tech.souyunku.com/root/.pm2)
root 818 0.0 1.5 737300 29832 ? Ssl Sep20 68:25 /usr/bin/dockerd
root 12348 0.0 1.7 571116 32760 ? Ssl Nov05 0:06 node /root/download/node/bin/configurable-http-proxy --ip --port 8000 --api-ip 127.0.0.1 --api-port 8001
root 819 0.3 1.8 993740 34320 ? Ssl Sep20 339:30 /usr/bin/taosd
root 23187 0.0 1.8 256672 35464 ? S Oct22 5:39 python app.py runserver -h 0.0.0.0
root 12342 0.0 2.7 766296 52152 pts/3 Ssl+ Nov05 3:39 /usr/local/bin/python3.6 /usr/local/bin/jupyterhub
jupyter 12617 0.0 3.3 719872 63920 ? Ssl Nov05 0:14 /usr/local/bin/python3.6 /usr/local/bin/jupyterhub-singleuser --port=53971
mysql 18832 0.0 6.3 995620 119772 ? Sl Nov20 1:21 /application/mysql-5.6.42/bin/mysqld --basedir=/application/mysql-5.6.42 --datadir=/application/mysql-5.6.
101 14398 0.0 9.0 1153192 170700 pts/2 Sl Oct31 18:43 /usr/sbin/mysqld --user=root
root 1066 0.1 14.7 2569628 277748 ? Sl Nov02 37:15 /usr/java/latest/bin/java -Djava.util.logging.config.file=/usr/local/tomcat//conf/logging.properties -Djav
[root@test ~]#
说明:–sort就是指定以某一字段排序
方法二
[root@test ~]#ps aux |awk '{if(NR != 1){print $4,$0}}'|sort -n
0.0 chrony 537 0.0 0.0 117784 1876 ? S Sep20 0:15 /usr/sbin/chronyd
0.0 root 10 0.0 0.0 0 0 ? S< Sep20 0:00 [lru-add-drain]
0.0 root 10504 0.0 0.0 0 0 ? S 14:28 0:00 [kworker/0:1]
0.0 root 1081 0.0 0.0 113544 976 pts/0 S+ 22:13 0:00 awk {if(NR != 1){print $4,$0}}
0.0 root 1082 0.0 0.0 116500 920 pts/0 S+ 22:13 0:00 sort -n
0.0 root 11 0.0 0.0 0 0 ? S Sep20 0:18 [watchdog/0]
0.0 root 12341 0.0 0.0 127900 1496 ? Ss Nov05 0:00 SCREEN -A jupyterhub
0.0 root 12552 0.0 0.0 127768 1412 ? Ss Nov05 0:00 SCREEN -S jupyerhub
0.0 root 13 0.0 0.0 0 0 ? S Sep20 0:00 [kdevtmpfs]
0.0 root 14 0.0 0.0 0 0 ? S< Sep20 0:00 [netns]
0.0 root 14251 0.0 0.0 99980 1604 ? Sl Oct31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8888 -container-ip 172.17.0.2 -container-port 80
0.0 root 14261 0.0 0.0 99980 1604 ? Sl Oct31 0:01 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2031 -container-ip 172.17.0.2 -container-port 2031
0.0 root 14271 0.0 0.0 99980 1600 ? Sl Oct31 0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2021 -container-ip 172.17.0.2 -container-port 2021
0.0 root 14290 0.0 0.0 18364 1644 pts/2 Ss+ Oct31 0:00 /bin/bash /etc/gaga.sh
0.0 root 15 0.0 0.0 0 0 ? S Sep20 0:01 [khungtaskd]
0.0 root 16 0.0 0.0 0 0 ? S< Sep20 0:00 [writeback]
0.0 root 17 0.0 0.0 0 0 ? S< Sep20 0:00 [kintegrityd]
0.0 root 18 0.0 0.0 0 0 ? S< Sep20 0:00 [bioset]
0.0 root 19 0.0 0.0 0 0 ? S< Sep20 0:00 [bioset]
0.0 root 20 0.0 0.0 0 0 ? S< Sep20 0:00 [bioset]
0.0 root 2 0.0 0.0 0 0 ? S Sep20 0:00 [kthreadd]
0.0 root 21 0.0 0.0 0 0 ? S< Sep20 0:00 [kblockd]
0.0 root 22 0.0 0.0 0 0 ? S< Sep20 0:00 [md]
0.0 root 23 0.0 0.0 0 0 ? S< Sep20 0:00 [edac-poller]
0.0 root 24 0.0 0.0 0 0 ? S< Sep20 0:00 [watchdogd]
0.0 root 244 0.0 0.0 0 0 ? S< Sep20 0:00 [ata_sff]
0.0 root 260 0.0 0.0 0 0 ? S Sep20 0:00 [scsi_eh_0]
0.0 root 261 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_tmf_0]
0.0 root 262 0.0 0.0 0 0 ? S Sep20 0:00 [scsi_eh_1]
0.0 root 263 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_tmf_1]
0.0 root 266 0.0 0.0 0 0 ? S< Sep20 0:00 [ttm_swap]
0.0 root 274 0.0 0.0 0 0 ? S< Sep20 0:16 [kworker/0:1H]
0.0 root 283 0.0 0.0 0 0 ? S Sep20 0:30 [jbd2/vda1-8]
0.0 root 284 0.0 0.0 0 0 ? S< Sep20 0:00 [ext4-rsv-conver]
0.0 root 2858 0.0 0.0 0 0 ? S Nov01 0:02 [kworker/u2:1]
0.0 root 29972 0.0 0.0 0 0 ? S Nov20 0:00 [kworker/0:2]
0.0 root 30 0.0 0.0 0 0 ? S Sep20 0:01 [kswapd0]
0.0 root 3 0.0 0.0 0 0 ? S Sep20 0:18 [ksoftirqd/0]
0.0 root 31 0.0 0.0 0 0 ? SN Sep20 0:00 [ksmd]
0.0 root 32 0.0 0.0 0 0 ? SN Sep20 0:08 [khugepaged]
0.0 root 33 0.0 0.0 0 0 ? S< Sep20 0:00 [crypto]
0.0 root 41 0.0 0.0 0 0 ? S< Sep20 0:00 [kthrotld]
0.0 root 43 0.0 0.0 0 0 ? S< Sep20 0:00 [kmpath_rdacd]
0.0 root 44 0.0 0.0 0 0 ? S< Sep20 0:00 [kaluad]
0.0 root 45 0.0 0.0 0 0 ? S< Sep20 0:00 [kpsmoused]
0.0 root 46 0.0 0.0 0 0 ? S< Sep20 0:00 [ipv6_addrconf]
0.0 root 485 0.0 0.0 0 0 ? S< Sep20 0:00 [nfit]
0.0 root 490 0.0 0.0 55520 1104 ? S<sl Sep20 0:05 /sbin/auditd
0.0 root 5 0.0 0.0 0 0 ? S< Sep20 0:00 [kworker/0:0H]
0.0 root 519 0.0 0.0 26376 1744 ? Ss Sep20 0:15 /usr/lib/systemd/systemd-logind
0.0 root 525 0.0 0.0 25904 956 ? Ss Sep20 0:00 /usr/sbin/atd -f
0.0 root 527 0.0 0.0 126288 1624 ? Ss Sep20 0:09 /usr/sbin/crond -n
0.0 root 530 0.0 0.0 110104 876 ttyS0 Ss+ Sep20 0:00 /sbin/agetty --keep-baud 115200,38400,9600 ttyS0 vt220
0.0 root 531 0.0 0.0 110104 860 tty1 Ss+ Sep20 0:00 /sbin/agetty --noclear tty1 linux
0.0 root 59 0.0 0.0 0 0 ? S< Sep20 0:00 [deferwq]
0.0 root 6330 0.0 0.0 0 0 ? S Oct31 0:12 [kworker/u2:2]
0.0 root 7 0.0 0.0 0 0 ? S Sep20 0:00 [migration/0]
0.0 root 8 0.0 0.0 0 0 ? S Sep20 0:00 [rcu_bh]
0.0 root 874 0.0 0.0 115436 1768 ? S Sep20 0:00 /bin/sh /application/mysql-5.6.42/bin/mysqld_safe --datadir=/application/mysql-5.6.42/data --pid-file=/application/mysql-5.6.42/data/qiuping.pid
0.0 root 90 0.0 0.0 0 0 ? S Sep20 0:00 [kauditd]
0.0 root 9 0.0 0.0 0 0 ? R Sep20 7:21 [rcu_sched]
0.1 33 14402 0.0 0.1 33428 2432 pts/2 S Oct31 0:03 nginx: worker process
0.1 dbus 513 0.0 0.1 58220 2292 ? Ss Sep20 0:28 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
0.1 jupyter 12639 0.0 0.1 116840 3404 pts/5 Ss+ Nov05 0:00 /bin/bash -l
0.1 root 1 0.0 0.1 125460 3584 ? Ss Sep20 11:12 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
0.1 root 1080 0.0 0.1 155360 1892 pts/0 R+ 22:13 0:00 ps aux
0.1 root 12553 0.0 0.1 116388 3004 pts/4 Ss+ Nov05 0:00 /bin/bash
0.1 root 14275 0.0 0.1 264004 1900 ? Sl Oct31 0:01 docker-containerd-shim b06a869d21137a3dddbb60335a8adc23aaa1066c718ffc3439e65ade04e1e766 /var/run/docker/libcontainerd/b06a869d21137a3dddbb60335a8adc23aaa1066c718ffc3439e65ade04e1e766 docker-runc
0.1 root 14395 0.0 0.1 32720 3184 pts/2 S Oct31 0:00 nginx: master process /usr/sbin/nginx -g daemon off;
0.1 root 14397 0.0 0.1 237312 3468 pts/2 Sl Oct31 0:01 /usr/bin/duckchat-gateway-ubuntu -httpBackend=http://127.0.0.1/ 1>/dev/null
0.1 root 374 0.0 0.1 45012 2196 ? Ss Sep20 0:00 /usr/lib/systemd/systemd-udevd
0.1 root 548 0.0 0.1 116628 3252 pts/0 Ss 22:04 0:00 -bash
0.1 root 752 0.0 0.1 107464 2156 ? Ss Sep20 0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H qiuping eth0
0.1 root 820 0.0 0.1 41072 3220 ? Ssl Sep20 37:17 /usr/sbin/aliyun-service
0.1 root 905 0.0 0.1 125116 2272 ? Ss Nov02 0:00 nginx: master process /usr/sbin/nginx
0.2 nginx 906 0.0 0.2 125888 4052 ? S Nov02 0:03 nginx: worker process
0.2 root 1125 0.0 0.2 112864 4340 ? Ss Sep20 0:00 /usr/sbin/sshd -D
0.2 root 12512 0.0 0.2 32528 4228 ? S<sl Nov19 1:35 /usr/local/aegis/aegis_update/AliYunDunUpdate
0.3 root 534 0.0 0.3 157388 5984 ? Ss 22:04 0:00 sshd: root@pts/0
0.3 root 821 0.0 0.3 362012 6508 ? Ssl Sep20 3:44 /usr/sbin/rsyslogd -n
0.4 root 1113 0.0 0.4 242200 9324 ? Ssl Sep20 46:15 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
0.5 65534 18283 0.0 0.5 439532 10604 pts/2 S Nov19 0:00 php-fpm: pool www
0.5 65534 1944 0.0 0.5 439532 10600 pts/2 S Nov19 0:00 php-fpm: pool www
0.5 65534 28829 0.0 0.5 439336 9536 pts/2 S Nov21 0:00 php-fpm: pool www
0.5 65534 30518 0.0 0.5 439532 10612 pts/2 S Nov17 0:00 php-fpm: pool www
0.5 root 351 0.0 0.5 47328 9632 ? Ss Sep20 0:15 /usr/lib/systemd/systemd-journald
0.6 65534 13194 0.0 0.6 439676 12644 pts/2 S Nov18 0:00 php-fpm: pool www
0.6 65534 4633 0.0 0.6 439532 12620 pts/2 S Nov19 0:00 php-fpm: pool www
0.6 65534 8699 0.0 0.6 439704 13088 pts/2 S Nov16 0:00 php-fpm: pool www
0.6 polkitd 521 0.0 0.6 716592 11452 ? Ssl Sep20 0:11 /usr/lib/polkit-1/polkitd --no-debug
0.7 root 815 0.0 0.7 573920 14744 ? Ssl Sep20 9:33 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
0.8 root 12586 1.5 0.8 132912 15116 ? S<sl Nov19 78:13 /usr/local/aegis/aegis_client/aegis_10_75/AliYunDun
0.9 root 14391 0.0 0.9 54812 16956 pts/2 S+ Oct31 6:54 /usr/bin/python /usr/bin/supervisord --nodaemon --configuration /etc/supervisor/supervisord.conf
0.9 root 14396 0.0 0.9 438808 16952 pts/2 S Oct31 1:29 php-fpm: master process (https://tech.souyunku.com/etc/php/7.2/fpm/php-fpm.conf)
1.2 root 1460 0.0 1.2 613004 24204 ? Ssl Sep20 0:27 PM2 v3.5.1: God Daemon (https://tech.souyunku.com/root/.pm2)
1.5 root 818 0.0 1.5 737300 29832 ? Ssl Sep20 68:25 /usr/bin/dockerd
1.7 root 12348 0.0 1.7 571116 32760 ? Ssl Nov05 0:06 node /root/download/node/bin/configurable-http-proxy --ip --port 8000 --api-ip 127.0.0.1 --api-port 8001 --error-target http://127.0.0.1:8081/hub/error
1.8 root 23187 0.0 1.8 256672 35464 ? S Oct22 5:39 python app.py runserver -h 0.0.0.0
1.8 root 819 0.3 1.8 993740 34320 ? Ssl Sep20 339:32 /usr/bin/taosd
2.7 root 12342 0.0 2.7 766296 52152 pts/3 Ssl+ Nov05 3:39 /usr/local/bin/python3.6 /usr/local/bin/jupyterhub
3.3 jupyter 12617 0.0 3.3 719872 63920 ? Ssl Nov05 0:14 /usr/local/bin/python3.6 /usr/local/bin/jupyterhub-singleuser --port=53971
6.3 mysql 18832 0.0 6.3 995620 119772 ? Sl Nov20 1:22 /application/mysql-5.6.42/bin/mysqld --basedir=/application/mysql-5.6.42 --datadir=/application/mysql-5.6.42/data --plugin-dir=/application/mysql-5.6.42/lib/plugin --user=mysql --log-error=qiuping.err --pid-file=/application/mysql-5.6.42/data/qiuping.pid --socket=/application/mysql-5.6.42/tmp/mysql.sock --port=3306
9.0 101 14398 0.0 9.0 1153192 170700 pts/2 Sl Oct31 18:43 /usr/sbin/mysqld --user=root
14.7 root 1066 0.1 14.7 2569628 277748 ? Sl Nov02 37:16 /usr/java/latest/bin/java -Djava.util.logging.config.file=/usr/local/tomcat//conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat//endorsed -classpath /usr/local/tomcat//bin/bootstrap.jar:/usr/local/tomcat//bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/ -Dcatalina.home=/usr/local/tomcat/ -Djava.io.tmpdir=/usr/local/tomcat//temp org.apache.catalina.startup.Bootstrap start
[root@test ~]#
说明:以上方法利用awk把第四行字段取出来,然后在显示整行,然后对组合的条目排序。
2、编写脚本,使用for和while分别实现192.168.0.0/24网段内,地址是否能够ping通,若ping通则输出”success!”,若ping不通则输出”fail!”
1)for循环实现
[root@test ~]#cat ping.sh
#!/bin/bash
decare -i ipbegin=1
decare -i ipend=254
network="192.168.0."
for ip in `seq $ipbegin $ipend`;do
{
ping -c 1 -w 1 ${network}$ip &>/dev/null
if [ $? -eq 0 ];then
echo -e "\033[032m${network}$ip is success! \033[0m"
else
echo -e "\033[031m${network}$ip is fail! \033[0m"
fi
}&
done
wait
[root@test ~]#
2)c语言风格for循环实现
[root@test ~]#cat ping.sh
#!/bin/bash
declare -i ipbegin=1
declare -i ipend=254
network="192.168.0."
for((i=$ipbegin;i<=$ipend;i++));do
{
ping -c 1 -w 1 ${network}$i &>/dev/null
if [ $? -eq 0 ];then
echo -e "\033[032m${network}$i is success! \033[0m"
else
echo -e "\033[031m${network}$i is fail! \033[0m"
fi
}&
done
wait
3)while循环实现
[root@test ~]#cat ping.sh
#!/bin/bash
declare -i ipbegin=1
declare -i ipend=254
network="192.168.0."
while [ $ipbegin -le $ipend ];do
{
ping -c 1 -w 1 ${network}${ipbegin} &>/dev/null
if [ $? -eq 0 ];then
echo -e "\033[032m${network}${ipbegin} is success! \033[0m"
else
echo -e "\033[031m${network}${ipbegin} is fail! \033[0m"
fi
}&
let ipbegin+=1
done
wait
说明:while循环使用多线程的方式,需要把let ipbegin+=1放在”}&”之后,不能连let ipbegin+=1也括在里面。
3、每周的工作日1:30,将/etc备份至/backup目录中,保存的文件名称格式 为“etcbak-yyyy-mm-dd-HH.tar.xz”,其中日期是前一天的时间
1)编写备份脚本
[root@test ~]#cat backup.sh
#!/bin/bash
backup_file="/etc"
backup_dest="/backup"
[ ! -e $backup_dest ] && mkdir $backup_dest|| ture
[ $? -eq 0 ] && tar zcf ${backup_dest}/etcbak-`date -d 'yesterday' '+%F-%H-%M-%S'`.tar.xz $backup_file &>/dev/null
[root@test ~]#
2)制定计划任务
[root@test ~]#crontab -l
30 01 * * 1-5 root /bin/bash /root/backup.sh &> /dev/null
[root@test ~]#
4、工作日时间,每10分钟执行一次磁盘空间检查,一旦发现任何分区利用率高 于80%,就发送邮件报警
1)编写检查磁盘空间脚本
#!/bin/bash
for i in `df|awk '/^\/dev\//{print $5}'|cut -d '%' -f1`;do
if [ $i -gt 80 ];then
# /bin/wall "disk is full"
echo "disk is full" | mail -s "warning" 467697313@qq.com &> /dev/null
fi
done
[root@test ~]#
说明:以上脚本发送邮件需要先配置邮件
2)制定计划任务
[root@test ~]#crontab -l
*/10 * * * 1-5 root /bin/bash /root/checkdisk.sh &> /dev/null
[root@test ~]#