0

I was wondering how to execute all the commands present in a text file at the same time in Linux. Brief background- I have created a text file with content as below,

 nohup execute_command1
 nohup execute_command2
 .
 .
 .
 nohup execute_command30

And now I want to execute all the commands present in the text file at the same time in Linux server. How do I do that?

1

2 Answers 2

2

Put & at the end of each line.

Sign up to request clarification or add additional context in comments.

2 Comments

My question is how do I execute all the 30 commands in the file in my Linux server at the same time?
And the answer to your question is ... by putting an & at the end of each line!!
0

You have already created a file, you could turn this into a script by adding a hash bang to the top of the file (for bash use #!/usr/bin/env bash )

Then you can make that script executable by running chmod +x filename Then run the script with ./filename

This will run each of your commands in order, to run them all at the same time put & at the end of each command (as mentioned by @bib).

You file should look like

#!/usr/bin/env bash
command1 options &
command2 options &
....
commandn options &

All of the processed will be running in the background and the script will end. If these are long running processes you will need to find and kill the process once you are finished with it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.