LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-13-2004, 02:19 PM   #1
ridertech
Member
 
Registered: Dec 2003
Location: Seattle, Washington
Distribution: Debian 'Sarge'
Posts: 85

Rep: Reputation: 15
Scripting An Image's History?


I'm trying to track a web cam by using cron & wget, but I'm still very new to scripting...

Basically, I'd like to grab the cam's image every 15 minutes and keep only the last twenty images. In order to save storage space, I'd like to use the same twenty file names and just overwrite the oldest file.

I'm currently using the following crontab command to wget the images every 15 minutes...

0,15,30,45 * * * * root /usr/bin/webcam.sh >> /dev/null 2>&1

My scripting confusion begins with the file naming and only gets worse when I think of how to overwrite the oldest image.

Any advice would be of great help.
 
Old 12-13-2004, 02:31 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you can get the oldest file in a directory like this:
Code:
/bin/ls -t | tail -n 1
among dozens of other ways, that's what springs to mind for me.

in practise i'd probably take a different approach and use a datestamp to implictly overwrite it. if you write to a file called
Code:
image`date +%I%M`.png
then that will include a 12 hour clock in the filename. so every 12 hours that file will be over written. I presume 20 is actually an arbitrary figure?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
history junaid18183 Linux - General 14 11-07-2009 07:01 AM
history saipraveen Linux - Newbie 5 06-10-2005 07:04 PM
about history jackandking Programming 1 12-18-2004 02:10 PM
How to find back "history" database after "history -c" ? san_lss Linux - Newbie 1 01-07-2004 11:53 AM
History neohybrid1 Linux - General 1 12-03-2002 04:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration