0
我試圖運行一個PHP文件,該文件將每cren作業1分鐘創建.txt文件。wordpress cron-off-wordpress文件
PHP的下面的代碼工作:
$filename = 'test.txt';
$file = fopen($filename,"a+");
fwrite($file, "test");
fclose($file);
但是這只是用於測試。實際的腳本需要從wordpress(多站點)獲得變量,並且爲此我包含了wp-load.php和ms-load.php。
當我從瀏覽器輸入腳本時,它會創建它所需的txt文件,但是當cron作業嘗試這樣做時,它不起作用,並且不會給我txt文件。
- 我測試了包含路徑,它是正確的。
有問題的代碼是:
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);