简体   繁体   English

如何从Shell脚本运行Shell脚本而不终止它

[英]How to run shell script from a shell script without terminating it

I am working on a shell script which will install Debian packages for me, copy config files etc. 我正在开发一个Shell脚本,它将为我安装Debian软件包,复制配置文件等。

The problem is that when i try to execute external script, the parent script gets terminated, i have a script like this: 问题是当我尝试执行外部脚本时,父脚本被终止了,我有一个像这样的脚本:

# changing shell

chsh -s $(which zsh)

# installing oh-my-zsh

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my- 
zsh/master/tools/install.sh -O -)"

# copying zsh config file

rsync -a .zshrc ~/

My script terminates after running second step. 运行第二步后,我的脚本终止。

Thank you 谢谢

I think you need something like this 我想你需要这样的东西

sh -c "sleep 3" &
echo "We are waiting"
wait

Here you can check what the wait does https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html 在这里,您可以检查wait https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM