K
K
kursof2016-11-28 22:30:37
PHP
kursof, 2016-11-28 22:30:37

How to run my sql php via cron?

as I understand it, I need to make a separate file file.php insert into it

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

then insert a link to this file into the cron
/home/loginhosting/site.domain/www/file.php
like this or am I doing something wrong, but how can I protect this file

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Volf, 2016-11-28
@kursof

Protect this file - remove read and write permissions from everyone, except for the user from whom it will be launched, this is the first point.
The second point is that you don’t need to pervert like that over time, MySQL has standard functions for working with them, incl. function NOW() - returns the current date/time...
*about permissions, these will be permissions 500, but about working with dates in MySQL - it's well written here.
oh, and don't put a closing ?> tag at the end of a PHP file unless there's non-PHP code in there, this can cause potential problems with junk output to the browser and should become a habit even if the script is running outside of the browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question