(Líder Mundial con más de 100.000 web sites alojados)
Cómo hacer un cron
- -------------------------------------------------------
USING CRON
- -------------------------------------------------------
Cron jobs are a way of automating tasks that you want done every
week/month/day and at a certain time.
cron can update and create html files automatically without the need of any
person running a script, the server will handle that.
Note: cron needs full paths for everything.
- -------------------------------------------
A quick overview of how to use crontabs........
An example of a cron job could be:
25 0 1 * * /usr/forum/bin/monthly-diary-rotate.csh
which runs a script in /usr/forum/bin called monthly-diary-rotate.csh at
12:25 am on the first of every month.
- -------------------------------------------------------------
How can we tell that's what it does?
- -------------------------------------------------------------
An entry consists of two parts-- a time to run, and a command to run. (The
top line beginning with a # mark is a comment, and is only there to remind
people reading the file what the entry is there for.)
The time to run (the first part of the entry) is broken up into 5 fields:
minute of the hour
hour of the day (on the 24 hour clock)
day of the month
month of the year (1 = January, 2 = February, etc.)
day of the week (0 = Sunday, 1 = Monday, 2 = Tuesday, ..., 6 = Saturday)
A "*" in one of these fields indicates that the job should be executed at
any or every one of these, so for instance a "*" in the month of the year
field means that this task should be carried out every month at the time
specified in the other fields. A "*" in the day of the week field, when
there is something in the day of the month field, does not mean that this
task should be carried out every day, but rather that it should be carried
out on the appointed day of the month regardless of what weekday it is. Only
"*"s in the day of the week field,and the day of the month field, and the
month of the year field would indicate a daily task.
Examples: The job with this time to run would run every Sunday at 12:20 am.
20 0 * * 0
This job would run at midnight on any Friday the 13th.
0 0 13 * 5
You don't have to put just one time in a field. This job, for instance,
would run every day at 12:30am, 2:30am, 4:30am, 6:30am, 6:30pm, 8:30pm, and
10:30pm:
30 0,2,4,6,18,20,22 * * *
and this one would run every Tuesday and Friday at 5:30 am:
30 5 * * 2,5
create a new file named work.run
all crontabs you are running should also be placed in this file.
in this file you will put the following line
00 0 * * * /fullpathto/cgi-bin/whatever.cgi
This will run whatever.cgi everynight at 12 am ........
Change the 00 and * to whenever you want the script to be updated according
to what info is above....
Now upload this file (work.run) to your server
Telnet into your account and go to the dir you uploaded work.run into
Type: crontab work.run
This should set your cron job, to make sure type crontab -l