skip to Main Content

I’ve set Crons Job (CURL) from my server Cpanel exucate the Codeigniter controller every 1 hour.

Actually the url also can exucated manually by everyone if someone is visiting the url from browser.

My point of answer

I want to make sure this function exucated if the Request is from Crons Job method (CURL) at my server to prevent anyone exucated this function manually. How to do that with PHP?

Example

function clear_ip_addres(){ // every one hour
if(REQUEST IS COME FROM MY SERVER VIA CRONS JOB){ // << here is it
 //i will continue proceed the action
} else {
 // do nothing
}
}

2

Answers


  1. Instead of curl you can have your crontab execute via php instead, then you can use the input class to determine if the request is invoked via the command line:

    if($this->input->is_cli_request()){//}
    
    Login or Signup to reply.
  2. You have to validate Host IP and registered Domain before running cron job.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search