Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
知道如何创建脚本以测试与代表默认网关的 IP 的连接性。在连接的情况下,打印消息“默认网关打开”,如果未连接,则显示消息“默认网关关闭”
#!/bin/bash ping -c 1 192.168.1.1 2>&1 > /dev/null if [ $? -ne 0 ] then echo -e "host does not respond to ping" fi
Put this script in crontab and let it run every min or whatever frequency you want.