Shell脚本在延迟后产生一个进程 [英] Shell script spawning a process after a delay
本文介绍了Shell脚本在延迟后产生一个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Shell脚本中出现延迟后,如何生成一个进程?我希望命令在脚本启动后60秒启动,但是我希望继续运行脚本的其余部分,而不必先等待60秒.这是主意:
How can I spawn a process after a delay in a shell script? I want a command to start 60 seconds after the script starts, but I want to keep running the rest of the script without waiting 60 seconds first. Here's the idea:
#!/bin/sh
# Echo A 60 seconds later, but without blocking the rest of the script
sleep 60 && echo "A"
echo "B"
echo "C"
输出应为
B
C
... 60 seconds later
A
我需要能够在一个脚本中完成所有这一切.IE.没有创建从第一个外壳程序脚本调用的第二个脚本.
I need to be able to do this all in one script. Ie. no creating a second script that is called from the first shell script.
推荐答案
&开始后台工作,所以
& starts a background job, so
sleep 60 && echo "A" &
这篇关于Shell脚本在延迟后产生一个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文