首页 > 其他 > 详细

启动service的时候用nohup

时间:2014-02-27 01:10:53      阅读:666      评论:0      收藏:0      [点我收藏+]

这不是什么时候都出问题,不过在我两个用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.


启动service的时候用nohup,布布扣,bubuko.com

启动service的时候用nohup

原文:http://blog.csdn.net/csfreebird/article/details/19945947

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!