php - wordpress cron-jobs of off-wordpress file
I'm trying to run a PHP file that will create .txt file every 1 minute with cron jobs.
the following code of php is working:
$filename = 'test.txt'; $file = fopen($filename,"a+"); fwrite($file, "test"); fclose($file);
but that's just for testing. the actual script needs to get vars from wordpress (multisite) and for that I include wp-load.php and ms-load.php.
When I enter the script from browser it creates the txt files it needs to but when the cron jobs is trying to do so, it doesnt work and not giving me the txt files.
- I tested the include path and it's currect.
The problematic code is:
chdir(dirname(__FILE__)); require_once( '../wp-load.php' ); require_once( '../wp-includes/ms-load.php' ); global $wpdb, $post; $blog_list = wp_get_sites( 0, 'all' ); $filename = 'test.txt'; $file = fopen($filename,"a+"); fwrite($file, "test"); fclose($file);