O script shell pára automaticamente após cerca de 1 minuto

1

Eu escrevi este shell script muito feio que, em um ponto, funcionou perfeitamente. Agora funciona por um minuto ou dois e depois sai. Eu sei que é muito feio, mas funcionou, então eu nunca mudei. Alguém poderia me dizer o que está errado? Qualquer ajuda é muito apreciada:)

#!/bin/bash
echo "Starting..."
timestamphour='date +%F_%H'
mkdir /Some/Directory1
mkdir /Some/Directory2
mkdir /Some/Directory3
mkdir /Some/Directory4
mkdir /Some/Directory5
mkdir /Some/Directory6
mkdir /Some/Directory7
mkdir /Some/Directory8
mkdir /Some/Directory9

#This could be done in one step
mkdir /Some/Directory1/$timestamphour
mkdir /Some/Directory2/$timestamphour
mkdir /Some/Directory3/$timestamphour
mkdir /Some/Directory4/$timestamphour
mkdir /Some/Directory5/$timestamphour
mkdir /Some/Directory6/$timestamphour
mkdir /Some/Directory7/$timestamphour
mkdir /Some/Directory8/$timestamphour
mkdir /Some/Directory9/$timestamphour

for i in {1..3600}
do
#timestampmin='date +%F_%H-%M'
timestampsec='date +%F_%H-%M-%S'
sudo curl -o /Some/Directory1/$timestamphour/$timestampsec.jpg http://some.address.at.some:port1/jpg/image.jpg &
sudo curl -o /Some/Directory2/$timestamphour/$timestampsec.jpg http://some.address.at.some:port2/jpg/image.jpg &
sudo curl -o /Some/Directory3/$timestamphour/$timestampsec.jpg http://some.address.at.some:port3/jpg/image.jpg &
sudo curl -o /Some/Directory4/$timestamphour/$timestampsec.jpg http://some.address.at.some:port4/jpg/image.jpg &
sudo curl -o /Some/Directory5/$timestamphour/$timestampsec.jpg http://some.address.at.some:port5/jpg/image.jpg &
sudo curl -o /Some/Directory6/$timestamphour/$timestampsec.jpg http://some.address.at.some:port6/jpg/image.jpg &
sudo curl -o /Some/Directory7/$timestamphour/$timestampsec.jpg http://some.address.at.some:port7/jpg/image.jpg &
sudo curl -o /Some/Directory8/$timestamphour/$timestampsec.jpg http://some.address.at.some:port8/jpg/image.jpg &
sudo curl -o /Some/Directory9/$timestamphour/$timestampsec.jpg http://some.address.at.some:port9/jpg/image.jpg &
sleep 1
done
    
por Yllier123 04.12.2015 / 18:37

1 resposta

3

Tente usar wait em vez de sleep . wait esperará até que todos os processos em segundo plano sejam concluídos e, em seguida, continue, enquanto o tempo de espera atrasa apenas um segundo.

Veja se wait funciona

    
por 04.12.2015 / 20:31