Reputation: 501
I want to run multiple scripts/commands in parallel in bash. Here is the bash script :
python test_script.py &
docker stop process &
docker stop process1 &
sleep(1)
wait
docker start process1 &
docker start process &
wait
Here, im running multiple dockers and want to start/stop docker when my script python test_script.py is running.
for ex: python script is running and on parallel i want to stop process & process1 docker. python script is still in-progress and then say wait or sleep for 1 min and start the process again.
How can i achieve it ?
Upvotes: 2
Views: 6782
Reputation: 1319
From your original description, it seems that we can organize the problem into two scripts
test_script.py
A docker restart script say restart_docker.sh
which contains all the docker related commands that will be executed in sequence
docker stop process
sleep 1m
docker start process
With GNU parallel
, you can provide these two scripts as arguments to be executed in parallel
parallel ::: 'python test_script.py' 'bash restart_docker.sh'
Upvotes: 1
Reputation: 174
You can combine the following rules:
X; Y Run X and then Y, regardless of success of X
X && Y Run Y if X succeeded
X || Y Run Y if X failed
X & Run X in background.
Upvotes: 1