【发布时间】:2014-11-26 20:43:27
【问题描述】:
我在centos服务器上使用crontab
* * * * * php -q /var/www/domain.com/public_html/script.php
script.php 内容:
<?php
require_once( '/var/www/domain.com/public_html/wp-load.php' );
global $wpdb;
$results = $wpdb->get_var("SELECT post_date FROM wp_posts WHERE id = 70");
$fn = "/var/www/domain.com/public_html/file.txt";
$file = fopen($fn, "a+");
fwrite($file, $results."\n");
fclose($file);
?>
当我直接转到:http://www.domain.com/script.php 时,它执行良好并写入文件,当要执行 crontab 时,我没有从 db 到 file.txt 得到写入结果...有什么问题?它似乎不会加载 wp-load.php?有什么想法吗?
Crontab 正在工作,当我评论 wp-load.php 时它会写入文件...
【问题讨论】: