CentOS 5.5:服务在关机时没有停止

前端之家收集整理的这篇文章主要介绍了CentOS 5.5:服务在关机时没有停止前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我编写了脚本/etc/init.d/xxx,它在CentOS 5.5上启动/停止我的服务.

当我打电话给’service start xxx’或’service stop xxx’时,一切正常.
但是当我重新启动我的机器时,我在日志中看到,在关机时服务没有停止.

但是,它开始启动.

  1. > chkconfig --list xxx
  2. xxx 0:off 1:off 2:on 3:on 4:on 5:on 6:off

我做错了什么.
谢谢.

UPD:脚本的标题

  1. #!/bin/bash
  2. #
  3. # Startup script for the xxx
  4. #
  5. # chkconfig: 345 99 01
  6. # description: This script ...
  7. #
  8.  
  9. ### BEGIN INIT INFO
  10. # Provides: xxx
  11. # required-Start: $local_fs $network
  12. # required-Stop: $local_fs $network
  13. # Should-Start:
  14. ### END INIT INFO
我不是linux大师,实际上更像是一个菜鸟,但是为了执行关闭脚本,你必须在启动脚本的/ var / lock / subsys /文件夹中创建一个锁文件.
我在这里找到了答案:
CentOS Forum

脚本示例:

  1. #!/bin/sh
  2. # chkconfig: 345 98 11
  3. # description: my auto start-stop script.
  4.  
  5. echo "my service is doing something :)" >> /root/tempfile
  6. case "$1" in
  7. start)
  8. echo "my service started" >> /root/tempfile
  9. touch /var/lock/subsys/myservice
  10. echo "OK"
  11. ;;
  12. stop)
  13. echo "my service stoped" >> /root/tempfile
  14. rm -f /var/lock/subsys/myservice
  15. echo "OK"
  16. ;;
  17. esac

猜你在找的CentOS相关文章