Re: [PHP-ES] Configurar ejecución script php

From: Fernando Ortiz ( fortiz .en. lacorona.com.mx)
Date: Tue Mar 02 2004 - 15:55:53 CET


Hola Esteban,

Tienes que atacar el problema en dos fases:

1) Tener un script 'batch' que haga lo que tu quieres.

2) Programar ese script a que se ejectute periodicamente.

te explico con mas detalle (para un ambiente linux/unix)

1)

Lee el pagina del manual en linea de php.

-----
[web .en. web jrm]$ man php
PHP(1) Scripting Language
PHP(1)

NAME
       php PHP Command Line Interface 'CLI'

SYNOPSIS
       php [options] [ -f ] file [[--] args...]

       php [options] -r code [[--] args...]

       php [options] -- [ args...]

<snip>

TIPS
       You can use a shebang line to automatically invoke php from
scripts.
       Only the CLI version of PHP will ignore such a first line as
shown
       below:

              #!/bin/php
              <?php
               // your script
              ?>

<snip>

[web .en. web jrm]$ type php
php is hashed (/usr/local/bin/php)
[web .en. web jrm]$

-------------

En la seccion de TIPS mencionan que puedes hacer scripts que se ejectuten
desde la linea de comando, en mi caso el ejecutubale de php esta en
/usr/local/bin, Nota: no es el modulo de apache.

[web .en. web tmp]$ cat prueba.php
#!/usr/local/bin/php
<?php
   echo "hola\n";
?>
[web .en. web tmp]$ ./prueba.php
hola
[web .en. web tmp]$

2)

Lee el manual en linea de crontab.

Has un archivo que contenga la orden para ejecutar tu script a la hora y los
dias deseados (cronfile en mi caso).

Aqui lo programe todos los dias a la 1 de la mañana.

[web .en. web httpd]$ cat cronfile
0 1 * * * /home/httpd/bin/prueba.php

Carga ese comando en el spool de crontab

[web .en. web httpd]$ crontab cronfile

Verifica que este programado
[web .en. web httpd]$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (cronfile installed on Tue Mar 2 08:55:28 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
0 1 * * * /home/httpd/bin/prueba.php
[web .en. web httpd]$

Saludos

----- Original Message -----
From: "Esteban de Aymerich Lizariturry" < php .en. factorideas.com>
To: "Lista PHP" < php-es .en. lists.php.net>
Sent: Tuesday, March 02, 2004 7:39 AM
Subject: [PHP-ES] Configurar ejecución script php

> Hola listeros,
>
> Me gustaría saber cómo se podría hacer para ejecutar un script php a una
> hora determinada, y en caso afirmativo, cómo se podría hacer.
>
> Muchas gracias.
> Saludos,
> Esteban
>
>
> --
> PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Spanish Localization Talk Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


This archive was generated by hypermail 2.1.7 : Fri May 14 2004 - 16:04:33 CEST