case结构语句
【语法格式】
case “变量” in
1)
指令
;;
2)
指令
;;
* )
指令
exit
;;
esac
【手动自定义一个httpd的启动shell脚本】
#!/bin/sh
httpd="/application/apache/bin/httpd -k"
case "$1" in
start)
$httpd start > /dev/null
[ $? -eq 0 ] && echo "http is running" || echo "http is not running"
;;
stop)
$httpd stop > /dev/null
[ $? -eq 0 ] && echo "http is stopped" || echo "http is not stopped"
;;
restart)
$httpd restart > /dev/null
[ $? -eq 0 ] && echo "http is restarted" || echo "http is not restarted"
;;
*)
echo "Usage:$0 {start|stop|restart}"
exit
;;
esac
建议把linux下面系统启动脚本多学习 /etc/init.d/下面的系统启动脚本。