【发布时间】:2018-04-02 14:36:39
【问题描述】:
我每天对 100 个 IP 进行 ping 测试,输入文件 IP 每天都会更新,因为它是动态的。我指定 input(100 IP list) 作为第一个参数。因为下面的脚本将每 10 分钟运行一次
注意:- 我每天都使用不同的IP,所以需要每天凌晨12点更改输入文件
在 4 月 1 日凌晨 12 点作为后台运行脚本
sh ping.sh IPlist_apr1.txt &
第二天,我的辅助脚本(将创建更新的 IP)将以这种文件格式“IPlist_apr2.txt”选择其他 IP 集 第三天 - IPlist_apr3.txt ...它会每天在 CWD 上记录 $1.log。
同样,这个过程继续,我实际上正在寻找我的 ping 脚本应该每天处理列表作为第一个参数。
我的实际脚本的片段。
t=10m
ip=$1 #### specify the file having IP's
while sleep $t
do
if ping -c1 $ip >/dev/null 2>&1; then
echo "`date +%H:%M`: $ip is up";
else
echo "`date +%H:%M`: $ip is down";
fi >>$1.log;
done
【问题讨论】:
-
如果您打算使用
bash,为什么要使用sh调用脚本? -
有什么问题?
标签: bash