Paging Linux geeks -- please teach me the inner mysteries of cron and scripting. Simple questions follow.
Right now I have a Windows machine that downloads information off the web every hour. This computer is a 10-year old notebook computer that's about to fall apart, and I have a new computer on the way to replace it. I badly need a Linux system to run some institutional science apps, so it looks like I should go the Linux route.
Currently, my Windows scripting is orchestrated by a simple hand-coded application whose sole job is to call a different Windows batch file at 10 minutes past every hour (GET00.BAT, GET01.BAT .... GET23.BAT). Each batch file calls wget to download whatever data is needed. It works splendidly.
However it's not enough just to call the batch file... my app also has to form the pieces of the date/time and call them as arguments. For example today 2/21/07 4:00pm would be called as:
GET00.BAT 2007 02 21 16 00
(note that some are zero-padded). These date/time values are needed to construct target filenames and are used in some source URLs. For example, the command
WGET blah.com/junk.dat -O %1-%2-%3 would put my data into
2007-02-21.dat.
So my questions are essentially:
1) Is cron appropriate for this kind of work?
2) How can I set up a cron job where it runs all the time (i.e. when the computer is always on)? I'm not clear on how daemons are set up in a Linux desktop environment.
3) Can scripting devise these required time parameters explained above, or can cron pass them? Or is an ugly C++ program needed?
4) A real newbie question: Does my choice of a shell (ksh, csh, etc) matter much here?
Fortunately the data is not critical, so it's no biggie if I make some mistakes getting this set up. I'm just hoping for a push in the right direction. Thanks.
yourscript.sh `date +"%y"` `date +"%m"` `date +"%d"` `date +"%H"` `date +"%M"` `date +"%S"`
That passes the current year, month, day, hour, minute, and second to the shell script.
Each of those bits in backticks can be run independently at the command line to see what they'll give you. Read the man page for the date utility to see what values it can spit out.
posted by letourneau at 3:10 PM on February 21, 2007