Total Pageviews

Sunday 10 June 2018

又一个让进程在后台运行的工具:start-stop-daemon

登陆linux vps.
git clone https://github.com/daleobrien/start-stop-daemon
cd start-stop-daemon
gcc -o start-stop-daemon start-stop-daemon.c
(此命令会在当前目录下,生成可执行文件start-stop-daemon)


root@ar:~/start-stop-daemon# ./start-stop-daemon --start --exec /root/go/gopath/bin/GolangSocks5Server 2222 --background
root@ar:~/start-stop-daemon# ps aux|grep GolangSocks5Server
root     10796  1.8  0.9  62204 20848 ?        Sl   22:18   0:00 /root/go/gopath/bin/GolangSocks5Server 2222
root     10803  0.0  0.0  11072   844 pts/0    S+   22:19   0:00 grep GolangSocks5Server
root@ar:~/start-stop-daemon#

这样,命令:/root/go/gopath/bin/GolangSocks5Server 2222就在后台运行了。

项目地址:https://github.com/daleobrien/start-stop-daemon
(示范的在前台运行的程序例子GolangSocks5Server,
https://github.com/leechristensen/GolangSocks5Server)

相关帖子:https://briteming.blogspot.com/2017/10/centosstart-stop-daemon.html
类似的工具daemonize,http://briteming.blogspot.com/2016/08/daemonize-daemon.html

No comments:

Post a Comment