start-stop-daemon

入手

$ tar -xf dpkg_1.17.6.tar.xz
$ cd dpkg-1.17.6
$ sudo yum install ncurses-devel ncurses
$ ./configure
$ make
$ cd utils
$ sudo cp start-stop-daemon /usr/local/bin

使用

#!/bin/bash
DAEMON=/usr/bin/python
PIDFILE=/home/xxx/hoge.pid
DAEMON_ARGS=/home/xxx/hoge.py

case "$1" in
  "start")
    start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
   result=$?
   if [ $result != "0" ]
   then
     pid=`cat $PIDFILE`
     echo "daemon is already running. (pid=${pid})"
     exit 1
   fi
   ;;
 "stop")
   start-stop-daemon --stop --quiet --pidfile $PIDFILE
   result=$?
   if [ $result != "0" ]
   then
     echo "daemon is not running. (check $PIDFILE)."
     exit 1
   fi
   rm -f $PIDFILE
   ;;
esac

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2017-05-01 (月) 15:28:07 (2550d)