Can you spawn a process in a shell script?

混江龙づ霸主 提交于 2019-12-11 02:56:43

问题


I'm trying to get my #!/bin/sh shell script to start another application without pausing execution. That is I'm looking for a way to launch it in the background and have my shell script keep executing. I want it to work something like this:

# start daemon
start(){
success=`launch '/path/to/daemon'`
if [ $success != false ];then
echo 'daemon is now running'
fi

I'm also new to shell scripting so will the above (if launch existed) get the return of launch or the stdout set as $success?

I want to only use SH not BASH.


回答1:


Use '&' sign after program name to launch it in background. Putting a program in the background




回答2:


use NOHUP. http://en.wikipedia.org/wiki/Nohup and send output to log using >> mylogfilename



来源:https://stackoverflow.com/questions/7133396/can-you-spawn-a-process-in-a-shell-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!