我必须在cpanel中使用cron作业,并且我正在使用CodeIgniter。我的控制器路径 http://www.example.com/myfolder/application/controllers/cron/cron_controller.php 如何在 cron 中调用我的控制器。
在 crontab 中只需定义
0 * * * * php /controllers/cron/cron_controller.php
它会工作,这里*是变量(时间(
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
当您尝试运行 cron 时,您是从命令行运行的,但您仍然需要遍历索引。所以你的cron命令将是:
* * * * * php index.php cron cron_controller
https://www.codeigniter.com/userguide3/general/cli.html
这是
有效的. 只需在 cron 选项卡中输入这个
wget www.yourdomain.com/index.php/yourcontroller/yourfunction