-
#!/bin/bash
-
-
start(){
-
echo "service started!"
-
}
-
stop(){
-
echo "service stopped!"
-
}
-
-
-
case "$1" in
-
"start")
-
start
-
;;
-
"stop")
-
stop
-
;;
-
*)
-
echo "$0 {start|stop}"
-
exit 0
-
;;
-
esac
脚本很简单,接受start、stop和其他参数可以执行对应的操作。
通过这个示例可以扩展,写出功能更加完善的服务脚本。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29773961/viewspace-1769941/
,如需转载,请注明出处,否则将追究法律责任。