나는 정말 못생긴 쉘 스크립트를 작성했지만 어느 순간에는 괜찮게 작동했습니다. 이제 1~2분 동안 작동한 다음 종료됩니다. 못생긴 건 알지만 작동하므로 절대 바꾸지 않습니다. 누구든지 무엇이 잘못되었는지 말해 줄 수 있나요? 어떤 도움이라도 대단히 감사하겠습니다 :)
#!/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
답변1
wait
대신 사용해보세요 sleep
. wait
계속하기 전에 모든 백그라운드 프로세스가 완료될 때까지 기다리는 반면, 절전 모드는 잠시만 지연됩니다.
wait
작동하는지 확인하세요