你能在 shell 脚本中生成一个进程吗? [英] Can you spawn a process in a shell script?
问题描述
我正在尝试让我的 #!/bin/sh shell 脚本在不暂停执行的情况下启动另一个应用程序.那就是我正在寻找一种在后台启动它并让我的 shell 脚本继续执行的方法.我希望它像这样工作:
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
我也是 shell 脚本的新手,那么上面的(如果存在启动)会得到启动的 return 或 stdout 设置为 $success 吗?
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?
我只想使用 SH 而不是 BASH.
I want to only use SH not BASH.
推荐答案
使用 '&'在程序名称后签名以在后台启动它.将程序置于后台
Use '&' sign after program name to launch it in background. Putting a program in the background
这篇关于你能在 shell 脚本中生成一个进程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!