I used this cronjob to perform php script with sql query every minute:
* * * * * /usr/bin/php /local/path/to/file.php
Unfortunately, this triggers an error due to not knowing what Mysqli extension is.
therefore I used
* * * * * curl /localhost/server/root/path/to/file.php
This works, but I wonder if it is possible to specify local path of the file instead of adding php file to the apache project and running curl to execute it?
No one, but the crontab should run the file so it makes little sense to place it among other apache files. thanks
There is a hackish solution that is based on malicious users not knowing that they need to pass a query parameter:
crontab:
* * * * * curl /localhost/server/root/path/to/file.php?randomString=veryRandomString
php:
<?php
$authentication = isset($_GET['randomString']) ? $_GET['randomString'] : '';
if($authentication == "veryRandomString"){
//proceed
}else{
die();
}
Any other solution?
ERROR UPDATE: When I run in terminal this 2 commands I get:
/usr/bin/php /local/path/to/file.php // triggers mysqli error
php /local/path/to/file.php // successfull script execution
`whereis php` returns `/usr/bin/php`