run bash scripts in folder all at the same timeHow can I make my shell scripts run in a new console automatically?How can I run PHP scripts without prefixing my scripts with sudo?Ubuntu 14.04 not running Bash scripts in /etc/cron.dailyA bash script to copy all files of folders to a unique folder in DesktopHow to run bash command with arguments at scheduled timerun bash scripts via a gamepad/joystick on ubuntu-server?Bash script with smaller scripts internallyRun bash function every x minute(s)run bash script from linux partition, locate does not workBash script run with sudo privilege (within crontab and incrontab)
How to use Adostop Eco stop bath?
Where are the Wazirs?
What was the nature of the known bugs in the Space Shuttle software?
Strong Password Detection in Python
How to evaluate the performance of open source solver?
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
Chilling water in copper vessel
What term do you use for someone who acts impulsively?
Why do people prefer metropolitan areas, considering monsters and villains?
How do I separate enchants from items?
Intern not wearing safety equipment; how could I have handled this differently?
With a data transfer of 50 GB estimated 5 hours, are USB-C claimed speeds inaccurate or to blame?
Is it okay to use open source code to do an interview task?
How do I talk to my wife about unrealistic expectations?
What was the profession 芸者 (female entertainer) called in Russia?
Can Jimmy hang on his rope?
Writing an ace/aro character?
Who goes first? Person disembarking bus or the bicycle?
Why do airports remove/realign runways?
What does the multimeter dial do internally?
Is there a formal/better word than "skyrocket" for the given context?
Why does Trump want a citizenship question on the census?
Write a function
Findminimum of Integral
run bash scripts in folder all at the same time
How can I make my shell scripts run in a new console automatically?How can I run PHP scripts without prefixing my scripts with sudo?Ubuntu 14.04 not running Bash scripts in /etc/cron.dailyA bash script to copy all files of folders to a unique folder in DesktopHow to run bash command with arguments at scheduled timerun bash scripts via a gamepad/joystick on ubuntu-server?Bash script with smaller scripts internallyRun bash function every x minute(s)run bash script from linux partition, locate does not workBash script run with sudo privilege (within crontab and incrontab)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Let's suppose I have 5 bash (.sh
) scripts in a folder (my_folder
) and they are named as follows:
script_1.sh
script_2.sh
script_3.sh
script_4.sh
script_5.sh
How can I write a sixth bash script or just a one liner that will start running all these scripts together?
I need the 5 scripts to start running all together at the same time and not one after the other.
Any suggestion?
Thanks
bash scripts
add a comment |
Let's suppose I have 5 bash (.sh
) scripts in a folder (my_folder
) and they are named as follows:
script_1.sh
script_2.sh
script_3.sh
script_4.sh
script_5.sh
How can I write a sixth bash script or just a one liner that will start running all these scripts together?
I need the 5 scripts to start running all together at the same time and not one after the other.
Any suggestion?
Thanks
bash scripts
add a comment |
Let's suppose I have 5 bash (.sh
) scripts in a folder (my_folder
) and they are named as follows:
script_1.sh
script_2.sh
script_3.sh
script_4.sh
script_5.sh
How can I write a sixth bash script or just a one liner that will start running all these scripts together?
I need the 5 scripts to start running all together at the same time and not one after the other.
Any suggestion?
Thanks
bash scripts
Let's suppose I have 5 bash (.sh
) scripts in a folder (my_folder
) and they are named as follows:
script_1.sh
script_2.sh
script_3.sh
script_4.sh
script_5.sh
How can I write a sixth bash script or just a one liner that will start running all these scripts together?
I need the 5 scripts to start running all together at the same time and not one after the other.
Any suggestion?
Thanks
bash scripts
bash scripts
asked 8 hours ago
aaaaaaaaaa
1335 bronze badges
1335 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
To run all scripts at the same time (in parallel) use:
script_1.sh &
script_2.sh &
script_3.sh &
script_4.sh &
script_5.sh &
To run the one after the other (sequentially) use:
script_1.sh &&
script_2.sh &&
script_3.sh &&
script_4.sh &&
script_5.sh
Enhancement for comments
If you have 200 scripts you want to run at the same time (which might bog down the machine BTW) use this script:
#!/bin/bash
for Script in my_folder/*.sh ; do
echo "$Script" &
done
Set the script attributes to executable with the command:
chmod a+x /path/to/script.sh
The first time you run the script it will only echo the names of the 200 scripts it will be executing. When you are happy the right names are being selected edit the script and change this line:
echo "$Script" &
to:
"$Script" &
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
add a comment |
There's a tool for this, read man run-parts
.
For example, I do:
run-parts $visorhome/pbackup.d/
in my Palm Pilot backup script. $visorhome/pbackup.d/
:
01PopulateJpilot 02Extract_Pedometer 03URLs 04google 05Books 06Weight 07Sec 08Bkgm 50hardlinks
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
Good point. I do think you may still want to mention thatrun-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.
– Eliah Kagan
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1156434%2frun-bash-scripts-in-folder-all-at-the-same-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
To run all scripts at the same time (in parallel) use:
script_1.sh &
script_2.sh &
script_3.sh &
script_4.sh &
script_5.sh &
To run the one after the other (sequentially) use:
script_1.sh &&
script_2.sh &&
script_3.sh &&
script_4.sh &&
script_5.sh
Enhancement for comments
If you have 200 scripts you want to run at the same time (which might bog down the machine BTW) use this script:
#!/bin/bash
for Script in my_folder/*.sh ; do
echo "$Script" &
done
Set the script attributes to executable with the command:
chmod a+x /path/to/script.sh
The first time you run the script it will only echo the names of the 200 scripts it will be executing. When you are happy the right names are being selected edit the script and change this line:
echo "$Script" &
to:
"$Script" &
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
add a comment |
To run all scripts at the same time (in parallel) use:
script_1.sh &
script_2.sh &
script_3.sh &
script_4.sh &
script_5.sh &
To run the one after the other (sequentially) use:
script_1.sh &&
script_2.sh &&
script_3.sh &&
script_4.sh &&
script_5.sh
Enhancement for comments
If you have 200 scripts you want to run at the same time (which might bog down the machine BTW) use this script:
#!/bin/bash
for Script in my_folder/*.sh ; do
echo "$Script" &
done
Set the script attributes to executable with the command:
chmod a+x /path/to/script.sh
The first time you run the script it will only echo the names of the 200 scripts it will be executing. When you are happy the right names are being selected edit the script and change this line:
echo "$Script" &
to:
"$Script" &
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
add a comment |
To run all scripts at the same time (in parallel) use:
script_1.sh &
script_2.sh &
script_3.sh &
script_4.sh &
script_5.sh &
To run the one after the other (sequentially) use:
script_1.sh &&
script_2.sh &&
script_3.sh &&
script_4.sh &&
script_5.sh
Enhancement for comments
If you have 200 scripts you want to run at the same time (which might bog down the machine BTW) use this script:
#!/bin/bash
for Script in my_folder/*.sh ; do
echo "$Script" &
done
Set the script attributes to executable with the command:
chmod a+x /path/to/script.sh
The first time you run the script it will only echo the names of the 200 scripts it will be executing. When you are happy the right names are being selected edit the script and change this line:
echo "$Script" &
to:
"$Script" &
To run all scripts at the same time (in parallel) use:
script_1.sh &
script_2.sh &
script_3.sh &
script_4.sh &
script_5.sh &
To run the one after the other (sequentially) use:
script_1.sh &&
script_2.sh &&
script_3.sh &&
script_4.sh &&
script_5.sh
Enhancement for comments
If you have 200 scripts you want to run at the same time (which might bog down the machine BTW) use this script:
#!/bin/bash
for Script in my_folder/*.sh ; do
echo "$Script" &
done
Set the script attributes to executable with the command:
chmod a+x /path/to/script.sh
The first time you run the script it will only echo the names of the 200 scripts it will be executing. When you are happy the right names are being selected edit the script and change this line:
echo "$Script" &
to:
"$Script" &
edited 7 hours ago
Eliah Kagan
86.4k22 gold badges241 silver badges381 bronze badges
86.4k22 gold badges241 silver badges381 bronze badges
answered 8 hours ago
WinEunuuchs2UnixWinEunuuchs2Unix
53.3k14 gold badges103 silver badges206 bronze badges
53.3k14 gold badges103 silver badges206 bronze badges
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
add a comment |
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
thank you..the thing is that in my real case I have more than 200 scripts to run. so is there any way I can run all of them with a single command (i.e. without writing their file names)?
– aaaaa
8 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
@aaaaa I've changed the answer for 200 scripts.
– WinEunuuchs2Unix
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
thanks. it works.. the only thing I had to add to your last line was 'bash'. otherwise I get 'permission denied'.
– aaaaa
7 hours ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
@aaaaa Do you actually prefer that all 200+ scripts to run at the same time, or would you rather have some smaller number (say, 10) run at a time, with the others queued to run when one or more of them finishes and the number of currently running scripts drops below that number? (If you're interested in such solutions, I suggest editing your question with information about how many scripts you have, how long they tend to take to run, what kind of work they do, and so forth.)
– Eliah Kagan
1 hour ago
add a comment |
There's a tool for this, read man run-parts
.
For example, I do:
run-parts $visorhome/pbackup.d/
in my Palm Pilot backup script. $visorhome/pbackup.d/
:
01PopulateJpilot 02Extract_Pedometer 03URLs 04google 05Books 06Weight 07Sec 08Bkgm 50hardlinks
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
Good point. I do think you may still want to mention thatrun-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.
– Eliah Kagan
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
add a comment |
There's a tool for this, read man run-parts
.
For example, I do:
run-parts $visorhome/pbackup.d/
in my Palm Pilot backup script. $visorhome/pbackup.d/
:
01PopulateJpilot 02Extract_Pedometer 03URLs 04google 05Books 06Weight 07Sec 08Bkgm 50hardlinks
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
Good point. I do think you may still want to mention thatrun-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.
– Eliah Kagan
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
add a comment |
There's a tool for this, read man run-parts
.
For example, I do:
run-parts $visorhome/pbackup.d/
in my Palm Pilot backup script. $visorhome/pbackup.d/
:
01PopulateJpilot 02Extract_Pedometer 03URLs 04google 05Books 06Weight 07Sec 08Bkgm 50hardlinks
There's a tool for this, read man run-parts
.
For example, I do:
run-parts $visorhome/pbackup.d/
in my Palm Pilot backup script. $visorhome/pbackup.d/
:
01PopulateJpilot 02Extract_Pedometer 03URLs 04google 05Books 06Weight 07Sec 08Bkgm 50hardlinks
answered 7 hours ago
waltinatorwaltinator
23.7k7 gold badges42 silver badges72 bronze badges
23.7k7 gold badges42 silver badges72 bronze badges
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
Good point. I do think you may still want to mention thatrun-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.
– Eliah Kagan
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
add a comment |
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
Good point. I do think you may still want to mention thatrun-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.
– Eliah Kagan
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
@eliah-kagan Running "more than 200 scripts" "at the same time" seems unwise. It might be a good way to stress test a system
– waltinator
1 hour ago
Good point. I do think you may still want to mention that
run-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.– Eliah Kagan
1 hour ago
Good point. I do think you may still want to mention that
run-parts
executes the scripts sequentially rather than all at once as the OP requested. You're right, though, that running 200 scripts at once is unlikely to perform the same as running 5--and even if running them all at once doesn't cause any problems, it may still be unnecessary. I've commented to suggest the OP clarify their preferences in this regard.– Eliah Kagan
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
For those of you wondering what a Palm Pilot it it's like your smart phone, except in monochrome instead of color, except a keyboard instead of touch screen and lacking the phone component.
– WinEunuuchs2Unix
1 hour ago
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1156434%2frun-bash-scripts-in-folder-all-at-the-same-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown