shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Processos em BG e Wait


From: MrBiTs
Subject: Re: [shell-script] Processos em BG e Wait
Date: Sun, 30 Oct 2005 15:01:18 -0200
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051013)

> Humm... é só por em background então???
> ok!
> Muito obrigado!
> 
> Reinaldo Carvalho wrote:
> 

É só por em bg, e você ainda pode controlar a execução dos processos
utilizando o wait. Se após

#!/bin/bash
rsync -avx --delete maquina1::home /home &
rsync -avx --delete maquina2::mail /var/mail &
rsync -avx --delete maquina3::mysql /var/lib/mysql &

você colocar um wait, os comandos posteriores a esse wait somente serão
executados quando o último rsync finalizar. Digamos que você queira
enviar uma mensagem de "Sync Completed", você poderia fazer:

#!/bin/bash
rsync -avx --delete maquina1::home /home &
rsync -avx --delete maquina2::mail /var/mail &
rsync -avx --delete maquina3::mysql /var/lib/mysql &
wait
echo "Sync Completo"

Por outro lado, o comando wait também trabalha com PID, e você pode
informar ao usuário o momento que cada sincronização terminou, assim:

#!/bin/bash
rsync -avx --delete maquina1::home /home &
P1=$!
rsync -avx --delete maquina2::mail /var/mail &
P2=$!
rsync -avx --delete maquina3::mysql /var/lib/mysql &
P3=$!
wait $P1
echo "Sync Maquina1 Completo"
wait $P2
echo "Sync Maquina2 Completo"
wait $P3
echo "Sync Maquina3 Completo"


[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]