views:

999

answers:

7

I am using codeigniter. I want to know how to set up a cron job to check a table for expiring users and insert data in to another table with the list of expiring users. How to do that.

When i tried to write a script with controller and model to insert the table : Content-type: text/html


Fatal error: Class 'Controller' not found in /home/content/html/test/live/application/controllers/cron.php on line 2

+1  A: 

If you are looking on how to create cron job, then have a look at this:

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

But if you mean how to put expired users into another table, then you should show your table structure.

Sarfraz
+3  A: 

You can find some more information on making CodeIgniter CLI-accessible here: http://phpstarter.net/2008/12/run-codeigniter-from-the-command-line-ssh/

Next step is just using crontab -e to set up the cronjob.

Zack Effr
A: 

Depending on how you want this done, it may be better to do a MySQL Event and maybe a Stored Procedure that way you don't have to setup a cron job and you can move it from one database to another pretty easily.

http://dev.mysql.com/tech-resources/articles/mysql-events.html

Just my $0.02, it's all dependent upon what you are actually trying to accomplish

WarmWaffles
+2  A: 

I have a controller just for doing cron jobs - then I use wget as the cron command:

wget http://example.com/cron_controller/method

Here's a wiki entry that references other ways:

http://codeigniter.com/wiki/Category:Advanced::CronScript/

JayTee
+1  A: 

I did write a wiki article on this about 2 years ago. check the wiki, check the forums then check Google. 99% of the time one of those will help.

http://codeigniter.com/wiki/CI_on_the_command_line/

Phil Sturgeon
A: 

I've found some nice solution: CRON job i CodeIgniter

Content is in Polish but a simple example shows all.

derdiusz
A: 

My hosting site is godaddy which give the option to create a cron. All we need to do is write a plainphp page to do the job, with sql connection and all stuff and just upload to the godaddy server and create the cron. Thats it. Job is easier.

ASD

related questions