写一个脚本判断telnet和xinetd服务正常
时间: 2024-03-27 17:41:29 浏览: 135
远程开启telnet服务的脚本
3星 · 编辑精心推荐
好的,可以使用以下脚本来判断telnet和xinetd服务是否正常:
```
#!/bin/bash
# 检查telnet服务是否正常
telnet_status=$(systemctl status telnet | grep Active | awk '{print $2}')
if [ $telnet_status == "active" ]; then
echo "Telnet service is running"
else
echo "Telnet service is not running"
fi
# 检查xinetd服务是否正常
xinetd_status=$(systemctl status xinetd | grep Active | awk '{print $2}')
if [ $xinetd_status == "active" ]; then
echo "Xinetd service is running"
else
echo "Xinetd service is not running"
fi
```
该脚本首先检查telnet服务是否正常,如果服务状态是"active",则输出"Telnet service is running",否则输出"Telnet service is not running"。然后,它检查xinetd服务是否正常,如果服务状态是"active",则输出"Xinetd service is running",否则输出"Xinetd service is not running"。你可以在Linux终端中运行该脚本来检查telnet和xinetd服务的状态。
阅读全文