Php 如何为codeigniter设置cron作业url?

Php 如何为codeigniter设置cron作业url?,php,codeigniter,cron,Php,Codeigniter,Cron,我正在为我的网站使用Codeigniter。我必须使用cron作业来运行其中一个控制器函数。我正在使用网站中的路线。而且我也没有在url中使用index.php e、 这里欢迎是我的控制器,show是该控制器的函数名 我曾经这样用过, 0****php/home/username/public\u html/welcome/show 它给出的是“没有这样的目录” 如何在CPANEL中为上述url设置cron-jon 谢谢。您可以试试这个: wget api.example.com/index.p

我正在为我的网站使用Codeigniter。我必须使用cron作业来运行其中一个控制器函数。我正在使用网站中的路线。而且我也没有在url中使用index.php

e、 这里欢迎是我的控制器,show是该控制器的函数名

我曾经这样用过,

0****php/home/username/public\u html/welcome/show

它给出的是“没有这样的目录”

如何在CPANEL中为上述url设置cron-jon


谢谢。

您可以试试这个:

wget api.example.com/index.php/controller/function
使用:

作为crontab中的命令。例如:

0 * * * * php /home/username/index.php welcome show
资料来源(版本2.2.0)

资料来源(第3版。*)

资料来源(第4版。*) 您也可以尝试:

0 * * * * /usr/bin/curl --silent --compressed http://my-domain.com/welcome/show
或本地主机

0 * * * * /usr/bin/curl --silent --compressed http://localhost/welcome/show
我希望这会有所帮助。

我在cron下面使用了

php /full-path-to-cron-file/cron.php /test/index
资料来源:

这对我有用


感谢所有的

/usr/local/bin/php/home/username/public\u html/index.php控制器名称methodname

这对我很有用。

这是我使用的cron

/usr/bin/php/home/pia/www/jobs/index.php cron时事通讯

说明:

a) $\u服务器['DOCUMENT\u ROOT']=/home/pia/www

b) codeigniter网站root=/home/pia/www/jobs

c) “cron”=控制器名称

d) 'newsletter'=方法名称

我已经按照

 00 09-18 * * 1-5 /usr/bin/php /var/www/html/app/index.php crontest
crontest是控制器的名称,它还使用一个模型从数据库中提取数据并定期发送邮件(每周周一到周五上午9点到下午6点)


我刚才看了一个例子,很详细地解释了这一点。希望这对其他人也有用。

我正在使用codeigniter 3.0.3,我的服务器是hostgator。对我来说,下面的格式很好用

*/15 * * * * /opt/php55/bin/php /home/username/public_html/myapp/index.php reminders index
上面的命令每15分钟运行一次,命令中的提醒是控制器名称,索引是方法名称

watch -n60 curl [your application path]/check_banalce/user_balance

在我的例子中,我使用codeigniter,上面的命令每60秒执行一次check\u balance controller中的user\u balance函数。

在Linux EC2维护上,这起到了作用:

*/5 * * * * /usr/bin/php /var/www/html/cifolder/index.php [module] [function]

使用以下步骤通过cPanel设置cron作业:

  • 登录到您的cPanel界面
  • 转到“高级”部分
  • 单击“Cron作业”
  • 从提供的列表中选择特定时间
  • 您应该在“命令”字段中输入要运行的命令

  • 如果您正在使用cPanel,请使用以下命令:

    /usr/bin/curl -k http://my-domain.com/welcome/show
    

    这对我来说非常有效。

    如果您使用的是Hostgator(或任何其他Linux服务器),请尝试使用此服务器

    /opt/cpanel/ea-php72/root/usr/bin/php /YOUR_HOME_DIRECTORY/YOUR_USERNAME/public_html/marketing/index.php welcome emailcampaign 1
    
    例如,对我来说

    /opt/cpanel/ea-php72/root/usr/bin/php /home3/adnan/public_html/index.php welcome emailcampaign 101
    
    在哪里


    我正在使用hostgator的cpanel。
    我在用户控制器中创建了一个用户控制器和“run_cron_data”函数。
    命令:wget www.your_site_url.com/index.php/user/run_cron_data

    请参见下面的屏幕截图

    谢谢回复,这意味着像我的例子一样的url是
    0****wgethttp://my-domain.com/welcome/show
    ,是这样吗?我想是这样,你可以试试这个谢谢Suvash。。这个url适合我。wget yourSite.com/index.php/controller/methodi每分钟设置2个cron,这会创建许多tmp文件。如果使用它,请小心,因为基本上,
    wget
    将网站下载为文件,因此服务器上会有很多文件。例如,我运行了两次
    wget localhost/my_controller/auth
    ,然后使用
    [root@myserverbin]#ls-l | grep auth
    命令,我有两个文件:
    -rw-r--r--1根根目录57 Feb 27 07:53 auth
    -rw-r--r--1根目录57 Feb 27 07:53 auth.1
    谢谢,我用过这个,但它加载默认控制器。您使用的是最新版本的CI吗?@Sachin try/usr/local/bin/php/home/user/index.php欢迎秀技巧是加载不同于常规/usr/bin/phpt的php安装。在我的machineexcelente中没有
    /usr/local/bin/php
    ,在我的例子中是php/home/myusername/domains/example.com/public_html/index.php tasks inserttest,从理论上来说,这可以回答这个问题,在这里包括答案的基本部分,并提供链接供参考。感谢这个解决方案!这个解决方案的一个简单问题是,如果我在我的应用程序中有一个登录名,它会问我为什么以及如何避免它@雷什马D@sachin你可以试试
    0****php/home/username/public\u html/yourapp/index.php欢迎秀
    Hi,这是什么工具?你能解释一下吗
    /opt/cpanel/ea-php72/root/usr/bin/php /home3/adnan/public_html/index.php welcome emailcampaign 101
    
    welcome is the controller name
    emailcampaign is the function name of welcome controller
    101 = First argument of url.