PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 28, 2022

[FIXED] Codeigniter Cronjob for godaddy hosting

 January 28, 2022     codeigniter, cpanel, cron, php     No comments   

Issue

My website hosting server is Godaddy and website is www.5kcinema.com
I am using codeigniter framework
I have a script that runs and check whether movie is released today or not, if released date is today's date then movie is moved from upcoming movies to latest movies
My Controller file is Cron.php and function is index.

class Cron extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('listing_model');
    }

    public function index() {
        $tableName = 'movies_tbl m';
        $condition = "m.status=1 AND m.is_deleted=0 AND m.date_published='".date('Y-m-d')."'";
        $data = $this->listing_model->getAll($tableName, $condition, NULL, 1, 'object');

        if (count($data) > 0) {
            foreach ($data as $row) {
                $id = $row->id;
                $movie_data['mtype'] = 1;
                $this->listing_model->insert_update($tableName, $movie_data, $id); 
            }
        }
    }

}

I want this code to run in cron job every night at 12.01am


Solution

You can use this

1   0   *   *   *   /usr/local/bin/php /path-to-your-public_html/www.5kcinema.com/index.php cron


Answered By - Atal Prateek
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing