服务启动脚本模板

  1. #!/bin/bash
  2. # chkconfig: 345 99 99
  3. # description: this is a testsrv
  4. . /etc/init.d/functions
  5. lockfile=/var/lock/subsys/$0
  6. start(){
  7. if [ -e $lockfile ] ; then
  8. action "$0 is running"
  9. else
  10. touch $lockfile
  11. if [ "$?" -eq 0 ] ; then
  12. action "$0 start"
  13. else
  14. action "$0 failed" false
  15. fi
  16. fi
  17. }
  18. stop(){
  19. if [ -e $lockfile ] ; then
  20. rm -rf $lockfile
  21. if [ "$?" -eq 0 ] ; then
  22. action "$0 stop"
  23. else
  24. action "$0 stop failed" false
  25. fi
  26. else
  27. action "$0 is stoped"
  28. fi
  29. }
  30. restart(){
  31. start
  32. stop
  33. }
  34. status(){
  35. if [ -e $lockfile ] ; then
  36. action "$0 running"
  37. else
  38. action "$0 stoped"
  39. fi
  40. }
  41. usage(){
  42. echo "$0 {start|stop|status|restart}"
  43. }
  44. case $1 in
  45. start)
  46. start;;
  47. stop)
  48. stop;;
  49. restart)
  50. restart;;
  51. status)
  52. status;;
  53. *)

转载于:https://www.cnblogs.com/momenglin/p/8483269.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值