
		fernandojose
		
		(usa Red Hat)
		
		Enviado em 09/01/2023 - 17:23h 
		Boa tarde usuários,
Preciso de um script para rodar 1 comando por vez e não pode rodar mais de 1 mesmo comando ao mesmo tempo:
Segue um exemplo do que fiz, mas quero melhorar, esse já está funcionando,
Se alguém puder ajudar, agradeço,
###########   SERVER: SE02P745   #################
#!/bin/sh
#set -x
################################################################################################
# Definicao de variaveis e criacao de diretorios quando necessario.                            #
# VM Server: SE02P745 - PA3                                                                    #
#            SE06J259 - PA3                                                                    #
# LUNs PA3 - Server SE02P745                                                                   #
# VEEAM_REPO_PA3_01                                                                            #
# VEEAM_REPO_PA3_02                                                                            #
# VEEAM_REPO_PA3_03                                                                            #
# VEEAM_REPO_PA3_05                                                                            #
# LUNs PA3 - Server SE06J259                                                                   #
# VEEAM_REPO_PA3_06                                                                            #
# VEEAM_REPO_PA3_07                                                                            #
# VEEAM_REPO_PA3_08                                                                            #
################################################################################################
DATE=`date +%Y-%m-%d_%H:%M`
TIME="`date +%Y%m%d%H%M%S`"
#Verificar se está a rodar
export RUNNING=`ps -Tcjstv | grep "unmap"| wc -l`
while true
do
#Verificar se está a rodar
export RUNNING=`ps -Tcjstv | grep "unmap"| wc -l`
if [ $RUNNING -le 1 ];
        then
        DATE=`date +%Y-%m-%d_%H:%M`
        echo "TESTE OK-Running PA3-01"
        echo "VEEAM_REPO_PA3_01" >> /compellent-script/logs.txt
        echo $DATE >> /compellent-script/logs.txt
        nohup esxcli storage vmfs unmap --volume-label=VEEAM_REPO_PA3_01 &
        echo "###########################" >> /compellent-script/logs.txt
fi
sleep 3600
export RUNNING=`ps -Tcjstv | grep "unmap"| wc -l`
if [ $RUNNING -le 1 ];
           then
           DATE=`date +%Y-%m-%d_%H:%M`
           echo "TESTE OK-Running PA3-02"
           echo "VEEAM_REPO_PA3_02" >> /compellent-script/logs.txt
           echo $DATE >> /compellent-script/logs.txt
           nohup esxcli storage vmfs unmap --volume-label=VEEAM_REPO_PA3_02 &
           echo "###########################" >> /compellent-script/logs.txt
fi
sleep 3600
export RUNNING=`ps -Tcjstv | grep "unmap"| wc -l`
if [ $RUNNING -le 1 ];
              then
              DATE=`date +%Y-%m-%d_%H:%M`
              echo "TESTE OK-Running PA3-03"
              echo "VEEAM_REPO_PA3_03" >> /compellent-script/logs.txt
              echo $DATE >> /compellent-script/logs.txt
              nohup esxcli storage vmfs unmap --volume-label=VEEAM_REPO_PA3_03 &
              echo "###########################" >> /compellent-script/logs.txt
fi
sleep 3600
export RUNNING=`ps -Tcjstv | grep "unmap"| wc -l`
if [ $RUNNING -le 1 ];
              then
              DATE=`date +%Y-%m-%d_%H:%M`
              echo "TESTE OK-Running PA3-05"
              echo "VEEAM_REPO_PA3_05" >> /compellent-script/logs.txt
              echo $DATE >> /compellent-script/logs.txt
              nohup esxcli storage vmfs unmap --volume-label=VEEAM_REPO_PA3_05 &
              echo "###########################" >> /compellent-script/logs.txt
fi
sleep 3600
done