将shell脚本的执行过程和执行结果导入到log文件中

[root@localhost scripts]# vim ping.sh 
#!/bin/bash
set -x    ##分步执行
exec &> /tmp/log.txt   ##脚本执行的过程和结果导入/tmp/log.txt文件中

for ip in `seq 1 10`
do
    if ! ping -c1 192.168.10.$ip ;then
        echo $ip
        exit
    fi
done

猜你喜欢

转载自www.cnblogs.com/carriezhangyan/p/11319862.html
今日推荐