I am using CodeIgniter for my website. I have to use cron job to run one of controller function. I am using route in website. And also I am not using index.php
in URL.
e.g. http://example.com/welcome/show
, here welcome is my controller and show is function name of that controller.
I have used like this,
0 * * * * php /home/username/public_html/welcome/show
It is giving 'No such directory'
How can I set cron jon in cPanel for above URL.
Building a command line interface into your application can be a way to add extra utility to your application. Adding cron jobs (a.k.a. scheduled tasks) to your CodeIgniter application can provide additional utility.
Cron jobs are typically located in the spool directories. They are stored in tables called crontabs. You can find them in /var/spool/cron/crontabs. The tables contain the cron jobs for all users, except the root user.
Use:
php index.php welcome show
as command in your crontab. E.g.:
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
Source (ver. 4.*) http://codeigniter.com/user_guide/cli/cli.html
I have used below cron
php /full-path-to-cron-file/cron.php /test/index
source: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
This works for me.
Thanks to all
You can try with this one:
wget api.example.com/index.php/controller/function
You can also try:
0 * * * * /usr/bin/curl --silent --compressed http://example.com/welcome/show
Or localhost
0 * * * * /usr/bin/curl --silent --compressed http://localhost/welcome/show
I hope that is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With