Re: automated tasks help


Subject: Re: automated tasks help
From: Anthony Valentine (amv@akvalentine.com)
Date: Tue Nov 13 2001 - 20:41:12 AKST


Scott,

The cron command itself just starts the cron daemon, which is probably
already running. To schedule jobs with cron, use the crontab command.
Like so:
$ crontab -e

The -e switch is to edit the crontab file. You can also use the -l
switch just to display your existing crontab.

The contab man page can give you the details, but the basic format of
the crontab file is like this :

# Each crontab file entry consists of a line with six fields,
# separated by spaces and tabs, that contain, respectively:
# The minute (0 through 59)
# The hour (0 through 23)
# The day of the month (1 through 31)
# The month of the year (1 through 12)
# The day of the week (0 through 6 for Sunday through Saturday)
# The shell command
# Each of these fields can contain the following:
# A number in the specified range
# Two numbers separated by a dash to indicate an inclusive range
# A list of numbers separated by commas
# An * (asterisk); meaning all allowed values

For easy future reference, you can paste this pounded section into the
top of your crontab file.

This line is good to make sure thatr cron is working; if it is, the
timestamp on /tmp/crontest will always be the current time.

* * * * * touch /tmp/crontest

To schedule something every hour, just set the minute field to a single
value, like this:
0 * * * * ftpscript

This will run the script called ftpscript at the zero minute of every
hour, for every day.

Now, as for automating ftp with a script, I think that the best way to
do that is with 'expect'. Go to http://freshmeat.net/search?q=expect
for info and download. It's a really cool language based on tcl that
lets you automate any interactive, text based, program such as ftp and
telnet.

I think (please correct me if I am wrong) that ftp can be used
noninteractivly, but doing so doesn't allow for any decision making in
the process. This may not be a problem, depending on your situation, so
expect may be overkill.

In any case, expect is worth learning even if you decide not to use it
for this case.

Hope this helps!

Anthony

On Tue, 2001-11-13 at 11:41, Scott Johnson wrote:
>
> I've never had to do a automated task on my Linux box before and had a
> question.
>
> >From what I've read, I need to use the cron command & create a cron
> tab? Does this sound right?
>
> If so, can someone tell me if cron can do this before I start studying
> it too deeply. I need my Linux box every hour to upload some text
> files in a certain dir via FTP. Is this feasable w/ cron, or is there
> some easier/better/correct way to do this?
>
> Thanks in advance.
>
> Scott
>
>
>
>



This archive was generated by hypermail 2a23 : Tue Nov 13 2001 - 20:42:11 AKST