Reputation: 245
As of now I a using time parallel to run scripts in parallel. Example... First, I'll go to the directory where the scripts are located.
cd $DIR
Then, execute scripts
time parallel ::: $script1 $script2 $script3
This works well.
But what if the scripts are in different directory?
Upvotes: 5
Views: 1915
Reputation: 207465
If you don't need to cd
into each directory, you can simply do:
time parallel --dry-run ::: dirA/dirB/script1 dirC/dirD/script2
Sample Output
dirA/dirB/script1
dirC/dirD/script2
If you do need to cd
into each directory, you can do it like this:
time parallel --dry-run 'cd {//} && {/}' ::: dirA/dirB/script1 dirC/dirD/script2
Sample Output
cd dirA/dirB && script1
cd dirC/dirD && script2
Upvotes: 3
Reputation: 881
You can use an ampersand (&
) for background execution in bash, and (command)
to run command
in a subshell:
(cd $DIR1; $script1) &
(cd $DIR2; $script2) &
Upvotes: 7