Ahmed-Anas
Ahmed-Anas

Reputation: 5619

cron job on codeigniter password protected site

Hey guys hope you could help me out

I am trying to get a cron job to work with a codeigniter application but its just not happening. I have cpanel and ftp access.

The site is password protected. I have been googling for a long time with no luck.

I dont really know linux, and although I do intend to atleast learn the basics of linux commands later, but for now I just want a simple cron job to work.

basically to test the cron job, I have a method

public function update_cronjob2() {     
    $to = "[email protected]";
    $subject = "asdf!";
    $message="cronjob";

    mail($to,$subject,$message);
}

when I enter the url directly,i.e

http://www.site.com/my_directory/index.php/home/update_cronjob2

I get the email. but not with cron jobs.

This is what I have tried so far. Note that I have pasted everything as-is and only replaced the text for username, password and site. no symbols, etc added

wget --user='user123'--password='pass123' http://www.site.com/my_directory/index.php/home/update_cronjob2

AND

wget http://www.site.com/my_directory/index.php/home/update_cronjob2

and

$ cd /my_directory/project;$ php index.php home update_cronjob2

Upvotes: 0

Views: 331

Answers (1)

Robin Castlin
Robin Castlin

Reputation: 10996

Is it possible for you to place the cron outside the admin/user part of the site? It sounds like you need to be logged in to access given page. That's why your browser can handle it, but not the cron.

That, or you could do add this in your login part:

if ( ! in_array($this->uri->segment(1), array('cron'))) {
    // Login prompt
}

Or maybe you have some other issue?

Upvotes: 0

Related Questions