¿Cómo configurar la url del trabajo cron para codeigniter?
Estoy usando Codeigniter para mi sitio web. Tengo que usar cron job para ejecutar una de las funciones del controlador. Estoy usando la ruta en el sitio web. Y tampoco estoy usando índice.php en url.
P. Ej. http://my-domain.com/welcome/show , aquí welcome es mi controlador y show es el nombre de la función de ese controlador.
He usado así,
0 * * * * php /home/username/public_html/welcome/show
Está dando'No tal directorio'
¿Cómo puedo configurar cron jon en CPANEL para la url anterior?
Gracias.
10 answers
Uso:
php index.php welcome show
Como comando en su crontab. Por ejemplo:
0 * * * * php /home/username/index.php welcome show
Source (ver. 2.2.0) http://www.codeigniter.com/userguide2/general/cli.html
Source (ver. 3.*) http://www.codeigniter.com/user_guide/general/cli.html
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-17 02:35:05
He utilizado a continuación cron
php /full-path-to-cron-file/cron.php /test/index
Fuente: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
Esto funciona para mí.
Gracias a todos
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-22 10:02:58
Puedes probar con este:
wget api.example.com/index.php/controller/function
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-09 10:40:37
También puedes probar:
0 * * * * /usr/bin/curl --silent --compressed http://my-domain.com/welcome/show
O localhost
0 * * * * /usr/bin/curl --silent --compressed http://localhost/welcome/show
Espero que sea útil.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-10 05:07:28
/usr/local/bin/php /home/username/public_html/index.php controllername methodname
Esto funcionó para mí.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-09 09:25:06
Aquí está el cron que uso
/usr/bin/php /home/pia/www/jobs/index.php cron newsletter
Explicación:
A) $_SERVER ['DOCUMENT_ROOT'] = / home/pia / www
B) codeigniter website root = /home/pia/www / jobs
C) 'cron' = nombre del controlador
D) 'newsletter' = nombre del método
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-10 18:13:57
Lo he hecho como
00 09-18 * * 1-5 /usr/bin/php /var/www/html/app/index.php crontest
Crontest es el nombre del controlador que también utiliza un modelo para extraer datos de la base de datos y enviar correo periódicamente (entre las 9 AM y las 6 PM de lunes a viernes cada semana)
Acabo de ver esta página que explica muy detalladamente con ejemplo. Espero que esto sea útil para otros también.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-28 13:41:55
Estoy usando codeigniter 3.0.3 y mi servidor es hostgator. Para mí, el siguiente formato está funcionando bien
*/15 * * * * /opt/php55/bin/php /home/username/public_html/myapp/index.php reminders index
El comando anterior se ejecuta cada 15 minutos, los recordatorios en el comando son el nombre del controlador y el índice es el nombre del método.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-22 11:10:49
watch -n60 curl [your application path]/check_banalce/user_balance
En mi caso estoy usando codeigniter y el comando anterior ejecuta la función user_balance que se encuentra en el controlador check_balance cada 60 seg.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-05 11:57:18
En una intance de Linux EC2, esto funcionó:
*/5 * * * * /usr/bin/php /var/www/html/cifolder/index.php [module] [function]
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-30 10:21:11