`
xiaoheliushuiya
  • 浏览: 403632 次
文章分类
社区版块
存档分类
最新评论

启动service的时候用nohup

 
阅读更多

这不是什么时候都出问题,不过在我两个用boost::asio写的service需要安装成Linux service时,在用newlisp的(exec "service data_service start")来启动的时候,发现newlisp会挂起,这个问题我曾经在newlisp社区提过,直到我都已经忘记有这件事情都没有人回答。:(

不过今天再次遇到这个问题,决定尝试自己解决一下,首先推测是service的启动脚本写的有问题

原来的在/etc/init.d/data-service中有一行

./data_service ./config.xml &


这个data_service脚本文件在终端运行一切正常。

不过看了这个帖子后http://stackoverflow.com/questions/4797050/how-to-run-process-as-background-and-never-die

想起来,自己之前还用过nohup,用它试一下如何。

nohup ./data_service_d ./config.xml > /dev/null 2>&1 &

好,问题解决了。

解释在这里:

nohup means: Do not terminate this process even when the stty is cut off.
> /dev/null means: stdout goes to /dev/null (which is a dummy device that does not record any output).
2>&1 means: stderr also goes to the stdout (which is already redirected to /dev/null).
& at the end means: run this command as a background task.


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics