批量扫描某个网段中的主机(并发)
创建目录编写脚本文件
mkdir /root/ip_scan_shell/
touch /root/ip_scan_shell/online_server.txt
touch /root/ip_scan_shell/offline_server.txt
touch /root/ip_scan_shell/ip_scan.sh
写入下面shell到脚本文件中
#!/bin/bash
#!/bin/bash
#每次执行脚本时清理上一次运行的主机记录
> /root/ip_scan_shell/online_server.txt
> /root/ip_scan_shell/offline_server.txt
ip="192.168.100."
for host_number in {1..254}
do
( if ping ${ip}${host_number} -c 1 -w 1 &> /dev/null;then
echo "${ip}${host_number} server is online" | tee -a /root/ip_scan_shell/online_server.txt
else
echo "${ip}${host_number} server is offline" | tee -a /root/ip_scan_shell/offline_server.txt
fi ) &
done
wait
运行示例















![[创业之路-270]:《向流程设计要效率》-2-企业流程架构模式 POS架构(规划、业务运营、支撑)、OES架构(业务运营、使能、支撑)](https://i-blog.csdnimg.cn/direct/0bd00d7ad6334986893427cffc6beb99.png)




