将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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM