How to set cron job url for codeigniter?

前端 未结 13 1709
一个人的身影
一个人的身影 2020-11-30 23:17

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.

相关标签:
13条回答
  • 2020-11-30 23:25

    Set up cron jobs through cPanel using this procedure:

    1. Log on to your cPanel Interface.
    2. Go to ''Advanced' section.
    3. Click on "Cron Jobs".
    4. Select the specific time from the lists provided.
    5. You should enter the command to run in the "Command" field.

    0 讨论(0)
  • 2020-11-30 23:26

    On a Linux EC2 intance, this worked:

    */5 * * * * /usr/bin/php /var/www/html/cifolder/index.php [module] [function]
    
    0 讨论(0)
  • 2020-11-30 23:27

    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

    0 讨论(0)
  • 2020-11-30 23:28

    I am using codeigniter 3.0.3 and my server is hostgator. For me, the below format is working fine

    */15 * * * * /opt/php55/bin/php /home/username/public_html/myapp/index.php reminders index
    

    above command runs every 15 minutes, reminders in command is controller name and index is method name.

    0 讨论(0)
  • 2020-11-30 23:30

    If you are using the Hostgator(or any other Linux server) then try this one.

    /opt/cpanel/ea-php72/root/usr/bin/php /YOUR_HOME_DIRECTORY/YOUR_USERNAME/public_html/marketing/index.php welcome emailcampaign 1
    

    for example for me its

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

    where

    welcome is the controller name
    emailcampaign is the function name of welcome controller
    101 = First argument of url.  
    
    0 讨论(0)
  • 2020-11-30 23:38

    Here is the cron I use

    enter image description here

    /usr/bin/php /home/pia/www/jobs/index.php cron newsletter

    Explanation:

    a) $_SERVER['DOCUMENT_ROOT'] = /home/pia/www

    b) codeigniter website root = /home/pia/www/jobs

    c) 'cron' = controller name

    d) 'newsletter' = method name

    0 讨论(0)
提交回复
热议问题