Total Pageviews

Saturday, 27 August 2016

daemonize-把命令运行为daemon的工具

Command line utility to run a program as a Unix daemon 

Introduction

daemonize is a command-line utility that runs a command as a Unix daemon. See the accompanying man page for full details.

Installation

Please see the daemonize web page for details.
(安装如下:
git clone http://github.com/bmc/daemonize
cd daemonize
./configure
make
make install )

Author

Brian Clapper, bmc@clapper.org

Web Page

from https://github.com/bmc/daemonize,
https://github.com/bmc/daemonize/issues/13
--------------

用法:
以socks-tunnel-demo为例。
root@ary:~/daemonize# cd ~/socks-tunnel-demo
root@ary:~/socks-tunnel-demo# ls
Gemfile       README.md  coder.rb   local.rb
Gemfile.lock  buffer.rb  config.rb  remote.rb
root@ary:~/socks-tunnel-demo# daemonize -c . ruby remote.rb
The 'path' parameter must be an absolute path name.
root@ary:~/socks-tunnel-demo# which ruby
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby
root@ary:~/socks-tunnel-demo# daemonize -c . /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby remote.rb
root@ary:~/socks-tunnel-demo# ps aux|grep remote.rb
root      5872  0.7  5.0  77028 12848 ?        Ssl  02:51   0:00 /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby remote.rb
root      5877  0.0  0.3  11072   916 pts/0    S+   02:51   0:00 grep remote.rb

root@ary:~/socks-tunnel-demo#

在需要运行命令的目录里(比如上面的~/socks-tunnel-demo/),运行:
daemonize -c . /path/to/some_command 

注意:some_command必须以绝对路径显示,  比如上面的/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby