Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run bash script from another script without waiting for script to finish executing? [duplicate]

Is there any way to execute two bash scripts without the first one blocking? The following does not work:

exec ./script1.sh #this blocks! exec ./script2.sh 
like image 301
XåpplI'-I0llwlg'I - Avatar asked Jun 25 '12 05:06

XåpplI'-I0llwlg'I -


People also ask

Does bash wait for command to finish before executing next?

The bash wait command is a Shell command that waits for background running processes to complete and returns the exit status. Unlike the sleep command, which waits for a specified time, the wait command waits for all or specific background tasks to finish.

How do you run multiple scripts one after another but only after previous one got completed?

Using wait. We can launch a script in the background initially and later wait for it to finish before executing another script using the wait command. This command works even if the process exits with a non-zero failure code.

What is $@ in bash?

bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc.


1 Answers

Put & at the end of the line.

./script1.sh & #this doesn't blocks! ./script2.sh 
like image 93
OmnipotentEntity Avatar answered Oct 06 '22 15:10

OmnipotentEntity