centos編譯start-stop-daemon,支援最新的option(--chdir) start-stop-daemon 是 debian的工具。 在centos/redhat發布版本中沒有此庫。為了相容一些指令碼調用此程式,我們需要手工編譯此工具。 遺憾的是,你編譯運行之後,發現此版本不支援 --chdir的option, start-stop-daemon --help start-stop-daemon 1.9.18 for Debian - small and fast C version written byMarek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain. Usage: start-stop-daemon -S|--start options ... -- arguments ... start-stop-daemon -K|--stop options ... start-stop-daemon -H|--help start-stop-daemon -V|--version Options (at least one of --exec|--pidfile|--user is required): -x|--exec <executable> program to start/check if it is running -p|--pidfile <pid-file> pid file to check -c|--chuid <name|uid[:group|gid]> change to this user/group before starting process -u|--user <username>|<uid> stop processes owned by this user -n|--name <process-name> stop processes with this name -s|--signal <signal> signal to send (default TERM) -a|--startas <pathname> program to start (default is <executable>) -N|--nicelevel <incr> add incr to the process's nice level -b|--background force the process to detach -m|--make-pidfile create the pidfile before starting -R|--retry <schedule> check whether processes die, and retry -t|--test test mode, don't do anything -o|--oknodo exit status 0 (not 1) if nothing done -q|--quiet be more quiet -v|--verbose be more verboseRetry <schedule> is <item>|/<item>/... where <item> is one of -<signal-num>|[-]<signal-name> send that signal <timeout> wait that many seconds forever repeat remainder foreveror <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout> Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo) 3 = trouble 2 = with --retry, processes wouldn't die上面沒有我需要的--chdir的選項。 繼續google搜尋(ps: 一般這種英文庫的搜尋使用google, baidu基本搜尋不出有用的東東) 下面就是我的安裝過程 wget http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_1.17.1.tar.xztar -xf dpkg_1.17.1.tar.xz cd dpkg-1.17.1./configure >/dev/nullmake >/dev/nullcd utilsmakesudo cp start-stop-daemon /usr/local/bin/start-stop-daemon 提示: make >/dev/null 會報錯的,不管它。因為我們只需要後面的 cd utils中的start-stop-daemon 現在運行 start-stop-daemon --help, 結果如下,可以找到我想要的--chdir的選項了。 Usage: start-stop-daemon [<option> ...] <command> Commands: -S|--start -- <argument> ... start a program and pass <arguments> to it -K|--stop stop a program -T|--status get the program status -H|--help print help information -V|--version print version Matching options (at least one is required): -p|--pidfile <pid-file> pid file to check -x|--exec <executable> program to start/check if it is running -n|--name <process-name> process name to check -u|--user <username|uid> process owner to check Options: -g|--group <group|gid> run process as this group -c|--chuid <name|uid[:group|gid]> change to this user/group before starting process -s|--signal <signal> signal to send (default TERM) -a|--startas <pathname> program to start (default is <executable>) -r|--chroot <directory> chroot to <directory> before starting -d|--chdir <directory> change to <directory> (default is /) -N|--nicelevel <incr> add incr to the process' nice level -P|--procsched <policy[:prio]> use <policy> with <prio> for the kernel process scheduler (default prio is 0) -I|--iosched <class[:prio]> use <class> with <prio> to set the IO scheduler (default prio is 4) -k|--umask <mask> change the umask to <mask> before starting -b|--background force the process to detach -C|--no-close do not close any file descriptor -m|--make-pidfile create the pidfile before starting -R|--retry <schedule> check whether processes die, and retry -t|--test test mode, don't do anything -o|--oknodo exit status 0 (not 1) if nothing done -q|--quiet be more quiet -v|--verbose be more verbose Retry <schedule> is <item>|/<item>/... where <item> is one of -<signal-num>|[-]<signal-name> send that signal <timeout> wait that many seconds forever repeat remainder foreveror <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout> The process scheduler <policy> can be one of: other, fifo or rr The IO scheduler <class> can be one of: real-time, best-effort or idle Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo) 2 = with --retry, processes would not die 3 = troubleExit status with --status: 0 = program is running 1 = program is not running and the pid file exists 3 = program is not running 4 = unable to determine status