I am having an issue within a custom cron script that I have located within a custom plugin I created for my WordPress site. I can execute the cron script via a web browser with no issues, however, when it is executed via the cron job, it continually errors out and says it can not connect to the database.
My cron script is located in my plugin folder:
/home/site/wwwroot/wp-content/plugins/PLUGIN/cron.php
Within the script I have have the following line:
require_once('includes/config.php');
In my /includes/config.php
file I have it set up to include the wp-config.php file:
define( 'ABSPATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/' );
require_once(ABSPATH . 'wp-config.php');
I have tried a few different ways to call the cron.php script but it appears that each time I still get the database connection error when running only from the cron tasks.
Any thoughts on how to get this to execute correctly?
Edit:
I forgot to mention, this is what is executed in my cron job:
cd D:\home\site\wwwroot\wp-content\plugins\PLUGIN\
php -f cron.php