-5

I am basically trying to write a bash script that suspends some virtual machines running on a host. However, if I write the script sequentially, VMs will be suspended one at a time. Suspending a VM takes some time to save state. How can I let my script suspend the VMs concurrently. In other words, how can I run commands concurrently in a bash script instead of sequentially?

Keeto
  • 4,074
  • 9
  • 35
  • 58

2 Answers2

2

You can background the tasks.

some bash command with options and stuff then with a &

Adding the & will send the command to the background and begin the next.

EvilKittenLord
  • 908
  • 4
  • 8
1

Put a & after the command for suspending the the VM.

For example if

cmd_to_suspend_vm

was your command to run. You would run

cmd_to_suspend_vm &
dostrander
  • 737
  • 5
  • 19