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:
Fatal error: Class 'Controller' not found in /home/content/html/test/live/application/controllers/cron.php on line 2
The App Engine Cron Service allows you to configure regularly scheduled tasks that operate at defined times or regular intervals. These tasks are commonly known as cron jobs. These cron jobs are automatically triggered by the App Engine Cron Service.
A cron job is a Linux command used for scheduling tasks to be executed sometime in the future. This is normally used to schedule a job that is executed periodically – for example, to send out a notice every morning. Some scripts, such as Drupal and WHMCS may require you to set up cron jobs to perform certain functions.
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.
This might not be what you're looking for, but it works just fine for me:
Create your CRON job logic as a 'normal' controller function.
Then, in your standard, non-CI, PHP cronjob file just load the URL via
file_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 will be at your disposal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With