Depends on your platform. But assume you are on LAMP,
1) to run php in command line, you could
php /public_html/yourscript.php
2) set up cron to run the above line automatically
0 php /public_html/yourfolder/yourscript.php
Note:
use physical full path in the script to make sure it will work.
Such as instead of relative path
require_once("../database/data_connection.php");
using the following line
require_once("/public_html/database/data_connection.php");