> -----Original Message-----
> From: ZHAO, BING [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 04, 2005 2:16 PM
> To: beginners@perl.org
> Subject: about cron and perl
> 
> Hi,
>            I was advised to check out man cron for how to use cron.
Set
> off do_it.pl using cron.
> But that's about it , all I can get from web help. I have no clue:
>            1. what should I include in the do_it.pl, say to delete
certain
> old files?

Admin caveat:  whenever deleting files via script, have your script
verify that it is in the _correct_ directory before performing any
delete operations.  _correct_ directory means wherever you want to
operate.  If you happen to be running the script as root (especially
automatically), this will save you much agony.  It's no fun having to
rebuild your system because a directory didn't exist and your script
defaulted to wherever the user's home directory is (in some *NIXes,
root's home dir is /).

>            2. this is a more unix problem, how should I exactly invoke
> "crontab do_it.pl", say I
> want cron to run do_it.pl everyday?
>             thank you all.

Well, cron reads crontab every minute.  man crontab will tell you this.

--snip--
       cron(8) examines cron entries once every minute.

       The time and date fields are:

              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sun, or use names)

       A  field  may  be an asterisk (*), which always stands for
       ``first-last''.
--end snip--

An example for you may be:

# run do_it.pl every 5 minutes, every day, every month, etc...
*/5 * * * * /some/path/do_it.pl

Note that your version of cron may not support the contracted steps such
as */5 so you may be forced to type out all the minutes that it would
run (i.e. 0,5,10,15, etc).  See your docs for more info.

ry

> 
> best,
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to