How can I run 2 commands simultanionsly?

Hi there, I wander is it theoretically possible that I can execute 2 commands at the same time using scripts?
Say I want to ping 2 hosts at the same time, how do I do it?
 
In shell you run them with & (to background).
You then immediately store their PID (process ID) via the $! variable.
And then you can use wait to halt execution until that process is complete.

For more info, check out: https://linuxhint.com/wait_command_linux/

I used to be worried about juggling PIDs like this because the kernel *can* reuse PIDs and I might get unlucky. However I then realised that wait can only wait on child processes, avoiding the problem altogether.

For more info check out:
 
Back
Top