chkconfig中添加自启动服务 2014-10-01 13:20

基本介绍

  • 添加脚本

以supervisor为例.只需要在/etc/init.d/下添加一个bash程序.文件名为supervisord,内容如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
#
# Startup script for the Supervisor
#
# chkconfig: 35 85 15
# description: Supervisor is a program administration tool.

case "$1" in
    start)
        /usr/bin/supervisord -c /etc/supervisord.conf
        ;;
    stop)
        /usr/bin/supervisorctl shutdown
        ;;
    status)
        if [ 1 == `ps -ef | grep /usr/bin/supervisord \
            | grep -v grep | awk '{print $9}' | wc -l` ]; then
             echo "supervisord is running"
        else
             echo "supervisord is not running"
        fi
        ;;
    restart)
        /usr/bin/supervisorctl shutdown
        /usr/bin/supervisord -c /etc/supervisord.conf
        ;;
    *)
        exit 1
        ;;
esac

exit 0
  • 添加服务

    chkconfig --add supervisord
Tags: #Shell    Post on Linux