Welcome Guest, Not a member yet? Register   Sign In
Submitting a form with a cron job?
#1

(This post was last modified: 03-26-2020, 01:54 PM by SmokeyCharizard.)

Hey fellas, its me again.

I'm trying to write a cron job for my codeigniter app, but I have now idea where to start. 

So far, I created a controller called 'cron' with the following:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//0 0 0 0 0 /usr/bin/php /home/your_site_user/public_html/index.php cron updateAge
class Cron extends CI_Controller 
{
    /**
     * This is default constructor of the class
     */
    public function __construct()
    {
        parent::__construct();
        $this->load->library('input');
        $this->load->model('cron_model');
    }
    
    
/**
     * This function is used to update the age of users automatically
     * This function is called by cron job once in a day at midnight 00:00
     */
    public function addProducts()
    {
        // is_cli_request() is provided by default input library of codeigniter
        if($this->input->is_cli_request())
        {            
            
// $this->cron_model->addProducts();
        }
        else
        {
            echo "You dont have access";
        }
    }
}
?>
 
My cron job has to submit form data in a view, and I thought this would help, but I don't think it will work.

I can't find any resources online for making cron jobs in codeigniter, so am I on the right track? I know that I need to execute the cron job file itself with a command (I found help here for that), but this is as far as I have gotten. 

Please help!
Reply


Messages In This Thread
Submitting a form with a cron job? - by SmokeyCharizard - 03-26-2020, 12:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB