This question has already been answered:

I understand that I need to insert a separate file.php file into it

<?php $this->db->query("DELETE FROM `paygo` WHERE created_date < ".( time()-60*2 )); // через 30 минут ?> 

then the link to this file is inserted into the cron

/home/loginhosting/site.domain/www/file.php

This is how I do something wrong, but how can we protect this file?

Reported as a duplicate by members aleksandr barakin , user194374, Denis Bubnov , Bald , Duck Learns to Take Cover December 18 '16 at 14:08 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • four
    Possible duplicate question: How to allow script execution only via cron? (in particular, this answer ). - aleksandr barakin
  • @alexanderbarakin here the question is correct I made a request for the krone? and not only did you read the last letter and immediately began commenting - kursof
  • What is the point of protecting him? You need it to be strictly executed once every half hour, if so, then you really need to protect it, otherwise the protection does not make any sense. Because Judging by the code, you just clean the table ... - fens
  • one
    @kursof judging by the code, it clears the records that are older than 2 minutes. - fens
  • one
    Well, and pull this file from anywhere ... From the fact that it will often be executed worse than no one. And as a measure of protection, you can put the rights to the file 555 - fens

1 answer 1

  1. The method above (see link). Often used in the framework for example with CodeIgniter

  2. Scripts in a separate folder with access to all through htaccess / usr / bin / php -f /home/loginhosting/site.domain/www/cron/file.php> / dev / null

  3. Just separate scripts out of sight of the host.

    / usr / bin / php -f /home/loginhosting/cron/file.php> / dev / null