PDA

View Full Version : Chron -- get a file and save with time name



TonyL
04-28-2006, 11:44 AM
I am trying to set up a chron job that gets a remote jpg file (which always has the same name) and then saves it with a name related to the date like "060428132000.jpg" where
06 - year
04 - month
28 - day
13 - hour
20 - minute
00 -- seconds

From the shell I tried wget and was able to get the file, so I presume that I should make a file that has:

line 1 gets the file and saves it as a temporary name using wget
line 2 renames the temp file "date".jpg with the mv command

#!/bin/sh
wget url-remote-file-name temp.jpg
Today="`date`" #with some kind of format like YYMMDDhhmm
mv temp.jpg $Today.jpg

Does that sound right?

Thanks -- Tony

jalal
04-28-2006, 12:50 PM
Yup.

Or even (untested):


FILENAME=`date +"%Y%m%d"`.jpg
wget remote-url $FILENAME


or something along those lines....
HTH