bymaker
bymaker

Reputation: 21

Limit WGET'ing by timer, how to do this?

Sorry for my english (i'm rus)

I save MJPEG stream from IP-camera with wget

wget -O 2010-01-12_01.mjpeg http://172.16.1.220:8070/video.mjpg

I need limit saving by hour (every hour is a another file - 2010-01-12_[XX])

What is the bast way to do it ? 1) starting and killing by cron ? 2) for .. do in script, how ? ...

thanks for answers

Upvotes: 0

Views: 3940

Answers (5)

n3ko
n3ko

Reputation: 415

You can use the timeout utility:

timeout 3600 wget -O `date +%Y-%m-%d_%T`.mjpeg http://172.16.1.220:8070/video.mjpg

Upvotes: 2

Marc
Marc

Reputation: 1

try curl with the -m or --max-time option

Upvotes: -1

Eddy
Eddy

Reputation: 1862

Just an alternate method to wget

while [ "true" ]; do 
ffmpeg -t 3600 -i http://172.16.1.220:8070/video.mjpg -vcodec mjpeg /path/to/storage/$(date +%Y-%m-%d_%H).mjpg
done

Upvotes: 0

richo
richo

Reputation: 8989

sweet as bash kludge

wget whatever &
sleep 60 && kill $$ 2>/dev/null

Upvotes: 0

Messa
Messa

Reputation: 25181

I'd use something like this:

( wget ... & sleep 3600; kill %1 )

Upvotes: 1

Related Questions