What i have now:
I have an "crontab.php" file, which ones is executed every minute from crontab commands like crontab.php * * * *
. In that file, i have some simple expressions, when the php scripts executes, like that, for example:
if ((date('H') == 8 && date('i') == 0) ||
(date('H') == 21 && date('i') == 0)){
file_get_contents("https://example/index.php?additional=test");}
So, it is not dynamic, as i wanted. I need to change this "crontab.php" file with this expressions to add something new. I have an idea - connect this commands to MySQL.
For this task, i have next structure: Example
I have next idea for now: "crontab.php" still running every minute, and in this file - i use mysqli_connect
and etc. for check command in database, and then running it, if is it time. I want a regular expression like "every hour" or "every day, in 8:00 and 23:00" etc. I think about next idea: I have column with cron_date
, which has "zero's" date and time. For example: 0000.00.01 00:00:00
means every day
, and 0000.00.00 12:00:00
means every 12 hours (twice at day)
, but scripts starts from exec_date
.
Current bad things:
- Database queries every minute
- Selecting all rows in database
- Maybe incorrect expressions in
exec_date
andcron_date
How, and which one is the correct way, to use MySQL database, like dynamically crontab? I don't want to edit crontab every time, i want to use database instead (where guest users can add tasks too)
I think it was all, what i want to know. If it has be something else - i write and answer ir in comments. Please, don't recommend me any of the libraries and etc. I want do it on pure PHP, with MySQL and crontab if possible
CodePudding user response: