LoginSignup
27
28

More than 5 years have passed since last update.

chkconfigを利用した起動スクリプトひな形

Posted at

下記のようなファイルを /etc/init.d/sample として置く。

/etc/init.d/sample
#!/bin/sh
# chkconfig: 345 99 1
# description: sample
# processname: sample

start() {
    echo -n "starting sample:"
    /usr/local/sbin/sample
    return 0
}

stop() {
    killall sample
    return 0
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    *)
        echo $"Usage: $0 {start|stop}"
        exit 2
esac

exit 0

# chkconfig [起動レベル] [起動時の優先度] [停止時の優先度]

追加方法

# chkconfig --add <起動スクリプト名>

# chkconfig <起動スクリプト名>  on
27
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
28