> -----Original Message-----
> From: Tony Gil
>
> I'm currently FTP'ing data from the HP-3000 to a Linux FTP server.
>
> I'm trying to run a script which will act like a "sleeper"
> job to be run on the Linux server. [...]
> If a file is not present, the job goes (back) to sleep for x
> minutes.
Actually, linux/unix already has a "sleeper" like component as part of the
standard -- known under various names such as "at", "cron", and "anacron",
with "cron" being the most prevailent.
Basically, you create a file known as a "crontab" which contains lines of
the form:
<minute> <hour> <day-of-month> <month> <day-of-week> [command]
Each of these "time" segments are separated by one or more space (no commas
or anything like that) and act somewhat like tumblers in a lock: when they
all line up to "the current time", the "command" gets executed [which is
usually the name of a script to invoke] The asterisk matches as a wildcard,
thus a line like this:
0 * * * * /home/anon/bin/checkftp
means run the "checkftp" script found in the "bin" subdirectory of the
"anon" user every hour ON the hour.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/anon/bin/checkftp
runs the same command every 5 minutes, but as you can see, that's a lot of
typing -- naturally, there is a shortcut:
*/5 * * * * /home/anon/bin/checkftp
the "/x" means "every 'x'th occurance", or in the example above, every 5
minutes.
for the month and day-of-week, the actual names can be used instead of
numbers, so:
0 0 * * sun /home/anon/bin/purgeoldftp
would run a script to purge any "leftover" files at midnight every sunday.
see the cron, crontab, and "crontab(5)" man pages for details (actually,
each page lists other related man pages to review) -- in cases where a
"segment" number is specifically mentioned, like "crontab(5)", the command
to use is as follows:
$ man 5 crontab
instead of just
$ man crontab
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|