Faizan Khattak
Faizan Khattak

Reputation: 882

How To Create CronJob in codeigniter?

How To Create CronJob in codeigniter?

I am basically insert values to a table of database at 6pm everyday through cronjob So how can i do that. Help me!

Thanks in Advance

Upvotes: 1

Views: 870

Answers (2)

Rid Iculous
Rid Iculous

Reputation: 3962

Create your CRON job logic as a 'normal' CI controller function.

Then, in your standard, non-CI, PHP cronjob file just load the URL of the controller via

get_get_contents('http:example.com/cronjob/');

This will treat the URL as being hit just as by any other user and the entire CI framework is at your disposal in the CI controller.

Upvotes: 0

JohnHeroHD
JohnHeroHD

Reputation: 194

You create a regular controller that performs the actions you wish the be executed, and then set up the cronjob in for example cPanel like this:

/usr/local/bin/php /home/sitefolder/public_html/index.php/controller/function

Upvotes: 2

Related Questions