

See our simple script file cat test_parallel.sh The only thing to note here is to put all these wget commands in background (shell background). The best method is to put all the wget commands in one script, and execute the script. I basically need to execute 3 wget commands and make them run in parallel. Running Commands in Parallel using Bash Shell Downloading all these files to a Linux machine can be done simultaneously to test and see how this parallel thing works. To demonstrate this, I have few junk files sitting in an object storage. We simply execute the command and then ask the shell to place that in background and proceed with the next command(while the first command is already being executed in the background), and then the next and so on. The very first one is using the bash shell job control mechanism. Let us dig through the different methods that are available in Linux, to execute commands simultaneously(in Parallel). Again, from a computer/CPU standpoint it mainly deals with one task at a time, but keeps on switching between tasks, which happens too fast, and we are perfectly fine as far as multiple tasks are progressing simultaneously. But if we have a method to run the command simultaneously across all the servers in parallel, then that saves a lot of time. If you go one by one, it will consume a lot of time. The best example is to execute a command across 10s of servers from a machine. In this article, we are going to discuss the methods available to execute multiple processes in parallel on a Linux system. When you have too many number of tasks waiting in line for CPU, then we say that the “machine is under load”. This switching is generally called as context switching. You can now imagine why we are under the illusion that multiple tasks are being executed at the same time.

A typical computer will do 100s of switching between tasks in a single second. This switching between tasks happens so fast that it is very difficult for us to notice.

But it will quickly switch to the next task, and then the next task and then the next (so basically in a way you can say that multiple tasks are progressing one by one). You might be running multiple things at the same time on a computer, but the computer will always execute one single task from your list of tasks at a time. Well, in most cases (with single core computers - meaning computers with one single CPU), the computer gives you an illusion that multiple things are happening simultaneously. Traditionally computers can only do one single thing at a time.
