Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to download file with different unique name each time

wget -O image.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"

Using wget's -O option overwrites file each time. What I want is: image-1.jpg, image-2.jpg, image-3.jpg etc. each time wget is run from cron.

share|improve this question
up vote 1 down vote accepted
wget -O image-`date +%H`.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"

If you are doing an hourly check. From looking at the URL you appear to be grabbing it from a webcam.

Your images should be labeled as:

  • image-01
  • image-02
  • [...]
  • image-14
  • image-15
  • [...]
share|improve this answer
Thanks, exactly what I need. – user36299 Feb 28 '10 at 17:43
Just realize that unless you throw another option to make like the day or something that it will overwrite the images daily. – David Rickman Feb 28 '10 at 18:02
ser=$(</var/local/image.ser); echo $((++ser)) > /var/local/image.ser; wget -O image-${ser}.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.