Running multiple shell instances with different parameters at the same time
up vote
0
down vote
favorite
Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh
), does it make sense to run run.sh
multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?
shell-script osx memory virtual-memory
add a comment |
up vote
0
down vote
favorite
Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh
), does it make sense to run run.sh
multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?
shell-script osx memory virtual-memory
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh
), does it make sense to run run.sh
multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?
shell-script osx memory virtual-memory
Assume I have a python script that I want to run with different parameter combinations (I have MacBook Pro). If I use a shell script to do so (say run.sh
), does it make sense to run run.sh
multiple times at the same time, each of which in different parameter combinations? In order word, do different parameter combinations touch each other while both are running in the memory? Is this something like the concept of memory protection?
shell-script osx memory virtual-memory
shell-script osx memory virtual-memory
asked Feb 17 at 23:00
Katherine
324
324
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
This depends very much on what the python script and run.sh
does.
So let's take a very simple example:
#!/bin/bash
s=$(( RANDOM%5 ))
echo Sleeping for $s > /tmp/foo
sleep $s
echo You entered $1 >> /tmp/foo
cat /tmp/foo
Now if I did
./run.sh 1 &
./run.sh 2 &
./run.sh 3 &
I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo
) that can not be accessed multiple times; one script will overwrite the results of another.
If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:
#!/bin/bash
tmpfile=$(mktemp)
s=$(( RANDOM%5 ))
echo Sleeping for $s > $tmpfile
sleep $s
echo You entered $1 >> $tmpfile
cat $tmpfile
rm $tmpfile
Now you can call this as many times as you like, and it will work properly.
Well... given memory and CPU limits, of course!
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
This depends very much on what the python script and run.sh
does.
So let's take a very simple example:
#!/bin/bash
s=$(( RANDOM%5 ))
echo Sleeping for $s > /tmp/foo
sleep $s
echo You entered $1 >> /tmp/foo
cat /tmp/foo
Now if I did
./run.sh 1 &
./run.sh 2 &
./run.sh 3 &
I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo
) that can not be accessed multiple times; one script will overwrite the results of another.
If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:
#!/bin/bash
tmpfile=$(mktemp)
s=$(( RANDOM%5 ))
echo Sleeping for $s > $tmpfile
sleep $s
echo You entered $1 >> $tmpfile
cat $tmpfile
rm $tmpfile
Now you can call this as many times as you like, and it will work properly.
Well... given memory and CPU limits, of course!
add a comment |
up vote
1
down vote
accepted
This depends very much on what the python script and run.sh
does.
So let's take a very simple example:
#!/bin/bash
s=$(( RANDOM%5 ))
echo Sleeping for $s > /tmp/foo
sleep $s
echo You entered $1 >> /tmp/foo
cat /tmp/foo
Now if I did
./run.sh 1 &
./run.sh 2 &
./run.sh 3 &
I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo
) that can not be accessed multiple times; one script will overwrite the results of another.
If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:
#!/bin/bash
tmpfile=$(mktemp)
s=$(( RANDOM%5 ))
echo Sleeping for $s > $tmpfile
sleep $s
echo You entered $1 >> $tmpfile
cat $tmpfile
rm $tmpfile
Now you can call this as many times as you like, and it will work properly.
Well... given memory and CPU limits, of course!
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
This depends very much on what the python script and run.sh
does.
So let's take a very simple example:
#!/bin/bash
s=$(( RANDOM%5 ))
echo Sleeping for $s > /tmp/foo
sleep $s
echo You entered $1 >> /tmp/foo
cat /tmp/foo
Now if I did
./run.sh 1 &
./run.sh 2 &
./run.sh 3 &
I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo
) that can not be accessed multiple times; one script will overwrite the results of another.
If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:
#!/bin/bash
tmpfile=$(mktemp)
s=$(( RANDOM%5 ))
echo Sleeping for $s > $tmpfile
sleep $s
echo You entered $1 >> $tmpfile
cat $tmpfile
rm $tmpfile
Now you can call this as many times as you like, and it will work properly.
Well... given memory and CPU limits, of course!
This depends very much on what the python script and run.sh
does.
So let's take a very simple example:
#!/bin/bash
s=$(( RANDOM%5 ))
echo Sleeping for $s > /tmp/foo
sleep $s
echo You entered $1 >> /tmp/foo
cat /tmp/foo
Now if I did
./run.sh 1 &
./run.sh 2 &
./run.sh 3 &
I will have no idea what the output would be. That's because the script has a single resource (/tmp/foo
) that can not be accessed multiple times; one script will overwrite the results of another.
If, instead, the script was written to use properly unique "temporary" resources then it can be called multiple times:
#!/bin/bash
tmpfile=$(mktemp)
s=$(( RANDOM%5 ))
echo Sleeping for $s > $tmpfile
sleep $s
echo You entered $1 >> $tmpfile
cat $tmpfile
rm $tmpfile
Now you can call this as many times as you like, and it will work properly.
Well... given memory and CPU limits, of course!
answered Feb 18 at 1:30
Stephen Harris
22.8k24176
22.8k24176
add a comment |
add a comment |
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%2funix.stackexchange.com%2fquestions%2f424875%2frunning-multiple-shell-instances-with-different-parameters-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