[root@CentOS8 ~]#ps axo user,cmd,%mem k -%mem |head -n20
USER CMD %MEM
root /usr/libexec/sssd/sssd_nss 1.9
root /usr/libexec/platform-pytho 1.6
polkitd /usr/lib/polkit-1/polkitd - 1.4
apache /usr/sbin/httpd -DFOREGROUN 1.0
apache /usr/sbin/httpd -DFOREGROUN 1.0
apache /usr/sbin/httpd -DFOREGROUN 1.0
root /usr/sbin/NetworkManager -- 0.9
root /usr/libexec/sssd/sssd_be - 0.7
root /usr/sbin/httpd -DFOREGROUN 0.7
root /usr/sbin/sssd -i --logger= 0.7
root /usr/sbin/ModemManager 0.6
root /usr/bin/vmtoolsd 0.5
root /usr/lib/systemd/systemd -- 0.5
root /usr/bin/VGAuthService -s 0.5
root sshd: root [priv] 0.5
root /usr/lib/systemd/systemd-ud 0.5
root /usr/sbin/cupsd -l 0.5
root /usr/sbin/rsyslogd -n 0.4
root /usr/lib/systemd/systemd -- 0.4
(1) for循环
[root@CentOS8 test]#cat scanhost.sh
#!/bin/bash
NET=192.168.0
for i in {1..254};do
(
ping -c1 -W1 ${NET}.${i} &> /dev/null && echo ${NET}.${i} : success || echo ${NET}.${i} :fail
)&
done
wait
(2) while循环
[root@CentOS8 test]#cat scanhost2.sh
#!/bin/bash
NET=192.168.0
i=1
while [ $i -lt 255 ];do
(
ping -c1 -W1 ${NET}.${i} &> /dev/null && echo ${NET}.${i} : success || echo ${NET}.${i} :fail
)&
let i++
done
wait
[root@CentOS8 backup]#crontab -l
30 1 0 /usr/bin/tar Jcf /backup/etcback-(date +\%F-\%H -d '-1 day').tar.xz /data/test
[root@CentOS8 backup]#cat /data/test/disk_check.sh
#!/bin/bash
WARNING=80
df |awk -F" +|%" '/^\/dev\/sd/{print $1,$5}' | while read DEVICE USED ;do
[ $USED -gt $WARNING ] && echo "$DEVICE will be full! Usage is $USED" | mail -s diskfull root
done [root@CentOS8 backup]#crontab -l*/10 * * * 1-5 /data/test/diskcheck.sh