作者:knight | 来源:互联网 | 2023-09-13 18:41
判断进程是否正常存在
[root@localhost shell]# cat http.sh
#!/bin/env
pgrep httpd &> /dev/null
if [ $? -ne 0 ];then
echo "no httpd"
else
echo "httpd"
fi
[root@localhost shell]# cat http1.sh
#!/bin/env
pgrep httpd &> /dev/null
test $? -eq 0 && echo "httpd" || echo "no httpd"
[root@localhost shell]#
判断网站服务是否正常
Wget curl elinks --dump
[root@localhost shell]# cat service.sh
#!/bin/env bash
web_server=www.itcast.cn
wget -P /root/shell $web_server &> /dev/null
[ $? -eq 0 ] && echo "service is ok" && rm -f /root/shell/index.* || echo "service is not ok"
[root@localhost shell]#
打印1,3,5,7,9
1-10 步长是2 (也就是间隔2)
[root@localhost shell]# seq 1 2 10
1
3
5
7
9
从0开始学习shell ---简单shell小程序练手
原文:https://blog.51cto.com/u_13625527/2729789