同时运行三个shell脚本 [英] Run three shell script simultaneously
问题描述
我有我下面连续3 shell脚本 -
I have three shell script which I am running as below-
sh -x script1.sh
sh -x script2.sh
sh -x script3.sh
所以,每个脚本在之后previous时间顺序1执行一条执行完毕。
So each script is executed sequentially one at a time after previous one finished executing.
问题陈述: -
有什么办法,我可以从一个单一的窗口中执行的同时所有上述三个脚本?
我只是想在同一时间执行SCRIPT1,SCRIPT2,script3。如果您认为某些cron作业调度 SCRIPT1凌晨3时许,SCRIPT2在凌晨3点,script3在凌晨3点
(所有三个脚本在同一时间,同时)的。这就是我需要,我需要同时执行所有的三个脚本。
Is there any way I can execute all the three above scripts at same time from a single window?
I just want to execute script1, script2, script3 at the same time. If you think of some CRON JOB scheduling script1 at 3 AM, script2 at 3AM, script3 at 3AM
(all three scripts at the same time, simultaneously). That's what I need, I need to execute all the three scripts simultaneously.
推荐答案
你想要这个?
$ sh -x script1.sh & sh -x script2.sh & sh -x script3.sh &
更新说明:
- ,以便在下一个命令,而无需等待当前命令完成运行在后台运行模式下,每个脚本。
-
'和;
使得脚本后台运行,这样的提示不会等待它完成 -
'和;
也可以用来链的命令上类似于在命令行中运行一个命令,一个接一个行
- Run each script in background mode so that next command is run without waiting for current command to complete.
'&'
makes the scripts run in background so that prompt does not wait for it to complete'&'
also can be used to chain commands on one line similar to running commands one by one on command line.
这篇关于同时运行三个shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!