I have to use a cron job in cpanel and I am using CodeIgniter. My controller path is http://www.example.com/myfolder/application/controllers/cron/cron_controller.php How am I call my controller in cron.
Asked
Active
Viewed 1,182 times
0
-
1In codeigniter we can not produce this url. And share some code what you have tried so far. – Bhavin Jun 19 '17 at 13:47
-
Thanks Bhavin,My code is working fine in url but cron is not working. I checked my code and that is correct. – Hemant Anjana Jun 19 '17 at 13:50
-
Try like curl "http://www.example.com/myfolder/application/controllers/cron/cron_controller?option=com_jnews&act=cron" – hrishi Jun 19 '17 at 14:23
-
Here is another [1]: https://stackoverflow.com/questions/19269566/how-to-set-cron-job-url-for-codeigniter/22995837#22995837 – Florin Jun 20 '17 at 03:23
3 Answers
0
In the crontab simply define
0 * * * * php /controllers/cron/cron_controller.php
it will work, Here * are variables (time)
Example of job definition:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * user-name command to be executed

Akshay Singhai
- 189
- 2
- 10
0
When you're trying to run cron, you're running from the command line, but you'll still need to go through the index. So your cron command would be:
* * * * * php index.php cron cron_controller

Joe
- 501
- 3
- 17
0
this is working . just type this in cron tab
wget www.yourdomain.com/index.php/yourcontroller/yourfunction

Rizwan Ali Khan
- 59
- 5