I wrote this very ugly shell script that, at one point, worked perfectly. Now it works for a minute or two and then exits. I know its very ugly but it worked so I never changed it. Could anyone tell me what's going wrong? Any help is greatly appreciated :)
#!/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
bash -x
does that show you anything of import?curl
processes with that script? i would look at some kind of sanity check limits - some limit on sockets or background jobs or whatever.echo $?
to get the exit code of whatever died. That may also be helpful, particularly if it'scurl
. I might also addtrap "pgrep curl | wc -l > /tmp/curl-process-count" EXIT
; this will drop a count of how many instances ofcurl
are running when the script dies into a small file.man curl
. on the first page you'll find info about wildcards and{brace,patterns}
, so you could dohttp://some.address.some:[0-9]/location/image[0-9].jpg
and so on. but you could probably just roll the whole thing into a singlecurl
invocation if you put a little time into learning it.