
29/05/2007, 19:28
|
| | Fecha de Ingreso: septiembre-2006
Mensajes: 141
Antigüedad: 18 años, 6 meses Puntos: 1 | |
Re: sistema Newsletter, ¿por donde empiezo? Esta parte explicativa no entraba en el post anterior, el script comienza con esta breve ayuda.
Usually regular tasks like backup up the site's database are run using cron
jobs. With cron jobs, you can exactly plan when a certain command is to be
executed. But most homepage owners can't create cron jobs on their web
server – providers demand some extra money for that.
The only thing that's certain to happen quite regularly on a web page are
page requests. This is where pseudo-cron comes into play: With every page
request it checks if any cron jobs should have been run since the previous
request. If there are, they are run and logged.
Pseudo-cron uses a syntax very much like the Unix cron's one. For an
overview of the syntax used, see a page of the UNIXGEEKS. The syntax
pseudo-cron uses is different from the one described on that page in
the following points:
- there is no user column
- the executed command has to be an include()able file (which may contain further PHP code)
All job definitions are made in a text file on the server with a
user-definable name. A valid command line in this file is, for example:
* 2 1,15 * * samplejob.inc.php
This runs samplejob.inc.php at 2am on the 1st and 15th of each month.
Features:
- runs any PHP script
- periodical or time-controlled script execution
- logs all executed jobs
- can be run from an IMG tag in an HTML page
- follow Unix cron syntax for crontabs
Usage:
- Modify the variables in the config section below to match your server.
- Write a PHP script that does the job you want to be run regularly. Be
sure that any paths in it are relative to pseudo-cron.
- Set up your crontab file with your script
- put an include("pseudo-cron.inc.php"); statement somewhere in your most
accessed page or call pseudo-cron-image.php from an HTML img tag
- Wait for the next scheduled run :)
Note:
You can log messages to pseudo-cron's log file from cron jobs by calling
logMessage("log a message");
Release notes for v1.2.2:
This release changed the way cron jobs are called. The file paths you specify in
the crontab file are now relative to the location of pseudo-cron.inc.php, instead
of to the calling script. Example: If /include/pseudo-cron.inc.php is included
in /index.php and your cronjobs are in /include/cronjobs, then your crontab file
looked like this:
10 1 * * * include/cronjobs/dosomething.php # do something
Now you have to change it to
10 1 * * * cronjobs/dosomething.php # do something
After you install the new version, each of your cronjobs will be run once,
and the .job files will have different names than before.
Ahora si, saludos. |