0

I have written bash shell script, which will download artifact and untar it and copy it to the destination folder. After that it does some more steps. and i am running this script from mco command which will execute in many hosts parallely. but i want restrict one perticular command to execute only once. how do i do that. except that command all other should execute in all host

myscript.sh :

if [ "$#" -eq 2 ]; then   
    Name=$1
    version=$2
    tarname=$Name"-"$version-SNAPSHOT.tar
    SNAPSHOT=$Name-$version-SNAPSHOT
    if [[ ! -e "/<path>/$tarname" && "/<path>/$SNAPSHOT" ]]; then

       do something  // this command i want to execute only once or only in one host. 
    fi

I execute this script like this :

mco shellcmd '/path/myscript.sh name version' -I /host-10[012345]/

this script executes in 50 host at a time but one particulate command should execute in only one host/one time.

how do we do this.

Thanks,

0

1 Answer 1

1

Check the hostname:

if [[ "$HOSTNAME" == "foobar" ]]; then
  echo "execute command here"
fi
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.