实战1:检查服务器运行状态脚本
[root@tzPC ~]# cat check.sh#!/bin/bash
if [ $# -ge 1 ] ;thensystemctl status $1 > /dev/null
if [ $? -eq 0 ];then
echo "$1 服务正在运行!"
elsesystemctl start $1
fi
else
echo "执行脚本的格式"
echo "sh $0 服务名"
fi
实战2:根据学生成绩判断优良中差
[root@tzPC ~]# cat check_cj.sh#!/bin/bash
read-p "请输入你的成绩"cjif [ $cj -ge 0 ] && [ $cj -le 59 ] ;then
echo "补考"
elif [ $cj -ge 60 ] && [ $cj -le 70 ] ;then
echo "良好"
elif [ $cj -ge 71 ] && [ $cj -le 85 ] ;then
echo "好"
elif [ $cj -ge 86 ] && [ $cj -le 100 ] ;then
echo "优秀"
else
echo "成绩的有效范围是0-100之间"
fi
实战3:每周一晚上3:00 ,备份数据库服务器上webdb库的所有数据到系统的/mysqlbak目录里,使用系统日期