简体   繁体   中英

How to setup Codeingiter controller to run with a cron job using cpanel

I am new with cron jobs , can any one explain me how to set up command or path from cpanel ? I'm using Codeigniter and I want to run the controller in a cron job using cpanel to create it.

This is my command or path:

/usr/bin/php -q /home/hktest1/public_html/application/controllers/cron >/dev/null 

Where the uri segment cron is the name of my controller.

Is this path correct or not? Somehow it's not working.

Since you only have a cpanel interface you can just create a cron.php file with something like:

<?php

$file = fopen ("http://example.com/index.php/controller/cronmethod", "r");
while (!feof ($file)) {
    $contents .= fgets ($file, 1024);
}
fclose($file);

?>

And then call it via cron like this:

/usr/bin/php -q /home/hktest1/public_html/cron.php

So it will be kinda wrapper for CI routes calling.

go to your host admin and schedule cron with wget command like

wget --tries=1 -a /home/wgetlog.txt https://www.example.com/index.php/controller/method

for more info :- http://linux.about.com/od/commands/l/blcmdl1_wget.htm

Also you can use elinks command

/usr/bin/elinks https://www.example.com/index.php/controller/method >/dev/null 2>&1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM