1、显示统计占用系统内存最多的进程,并排序。

ps aux --sort=-rss

2、编写脚本,使用for和while分别实现192.168.0.0/24网段内,地址是否能够ping通,若ping通则输出"success!",若ping不通则输出"fail!"

for循环:

#!/bin/bash
#
NetId=192.168.0.
declare -i HostId=1
for HostId in {1..254};do
{
    if /bin/ping -c 1 -W 1 $NetId$HostId > /dev/null;then
        echo "$NetId$HostId lived,Ping Test success!"
    else
        echo "$NetId$HostId not lived,Ping Test fail!"
    fi
} &
done
wait

while循环:

#!/bin/bash
#
NetId=192.168.0.
declare -i HostId=1
while [ $HostId -le 254 ];do
{
    /bin/ping -c 1 -W 1 $NetId$HostId > /dev/null
    if [ $? -eq 0 ];then
        echo "$NetId$HostId lived,Ping Test success!"
    else
        echo "$NetId$HostId not lived,Ping Test fail!"
    fi
} &
    let HostId++
done
wait

3、每周的工作日1:30,将/etc备份至/backup目录中,保存的文件名称格式 为“etcbak-yyyy-mm-dd-HH.tar.xz”,其中日期是前一天的时间

~]# crontab -e
30 1 * * 1-5 /usr/bin/tar -Jcf etcbak-`date -d "-1 day"+%Y-%m-%d-%H`.tar.xz /etc &> /dev/null

4、工作日时间,每10分钟执行一次磁盘空间检查,一旦发现任何分区利用率高 于80%,就发送邮件报警

VALUE=80
USAGEMAX=`df|sed -nr '/^\/dev\/sd/[email protected]* ([0-9]+)%.*@\[email protected]'|sort -nr|head -1`
if [ $USAGEMAX -gt $VALUE ];then
    echo "Disk usage is $USAGEMAX, please clean in time!" |mail -s "Warnig" [email protected]`hostname`
fi