views:

105

answers:

4

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

A: 

for...do.. in script sounds a easier solution, IMO.

Amit
A: 

Why not simply use the timeout parameter of wget?

-T seconds
--timeout=seconds

Set the network timeout to seconds seconds. This is equivalent to specifying --dns-timeout, --connect-timeout, and --read-timeout, all at the same time.

ammoQ
i think it's the best
bymaker
but it doen't work :)
bymaker
--timeout is as the name says, a timeout, aka, a maximum retrying/waiting time when there's an error. It does not impose a maximum downloading duration as the OP requested.
Florian
Florian: You are right, I should have RTFM
ammoQ
+1  A: 

I'd use something like this:

( wget ... & sleep 3600; kill %1 )
Messa
A: 

sweet as bash kludge

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