从0开始学习shell ---简单shell小程序练手

判断进程是否正常存在
[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小程序练手

上一篇:[c#]asp.net微信公众平台开发(3)微信消息封装及反射赋值


下一篇:shell 字符串判空