I have three shell script which I am running as below-
sh -x script1.sh
sh -x script2.sh
sh -x script3.sh
So each script is executed sequentially one at a time after previous one finished executing.
Problem Statement:-
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.
you want this?
$ sh -x script1.sh & sh -x script2.sh & sh -x script3.sh &
Update explanation :
- 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.
With GNU Parallel you can do:
parallel sh -x ::: script1.sh script2.sh script3.sh
If the scripts are executable then you can even do:
parallel ::: script1.sh script2.sh script3.sh
Watch the intro videos to learn more: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
10 seconds installation:
wget -O - pi.dk/3 | bash
The &
allows a process to run in the background.
sh -x script1.sh &
sh -x script2.sh &
sh -x script3.sh &
Not sure what you are trying to accomplish but you can create a script that calls these 3 or send them to background by adding a "&" at the end.
sh -x script1.sh &
sh -x script2.sh &
sh -x script3.sh &