在cron中出现错误:要求:找不到命令

时间:2019-05-24 05:47:40

标签: php cron

我已使用以下命令设置了cron:/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php,它每2分钟运行一次,我收到了它的电子邮件输出,并在该cron中得到了此错误,有人可以帮我解决此问题吗?

/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 1: ?php: No such file or directory
/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 3: require: command not found
/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 4: include: command not found
/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 5: global: command not found
/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 6: =: command not found
/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 7: syntax error near unexpected token `('
/mnt/md4/test/public_html/wp-content/plugins/website-custom-plugin/WCP/FrontEnd/cron.php: line 7: `$inventory_data = $wpdb->get_results($inventory_query);'

这是我的cron脚本的完整代码

require $_SERVER['DOCUMENT_ROOT'].'/wp-load.php';
include 'iCal.php';
global $wpdb;
$inventory_query = "SELECT * FROM ".$wpdb->prefix."inventory_ical";
$inventory_data = $wpdb->get_results($inventory_query);

error_reporting(E_ALL);
ini_set('display_errors', 1);

//dfsfsf

foreach($inventory_data as $key => $value) {
    $ical_airbnb = $value->ical_airbnb;
    $inventory_id = $value->inventory_id;

    $file = $ical_airbnb;
    $iCal = new iCal($file);
    $events = $iCal->eventsByDate();
    foreach ($events as $date => $event) { 

        $title = $event[0]->uid;
        $summary = '';
        if(isset($event[0]->summary)) {
            $summary = $event[0]->summary;
        }
        $description = '';
        if(isset($event[0]->description)) {
            $description = $event[0]->description;
        }
        $dateStart = $event[0]->dateStart;
        $dateEnd = $event[0]->dateEnd;
        $location = '';
        if(isset($event[0]->location)) {
            $location = $event[0]->location;
        }

        $airbnb_query = "SELECT * FROM ".$wpdb->prefix."rnb_availability WHERE block_by = 'AIRBNB' 
                        AND  pickup_datetime =  '".$dateStart."' AND  return_datetime =  '".$dateEnd."' AND inventory_id = '".$inventory_id."' ORDER BY created_at DESC ";
        $airbnb_data = $wpdb->get_results($airbnb_query);

        if(empty($airbnb_data)) {
            $data = array('post_type'=>'shop_order');
            $order_id = $wpdb->insert_id;
            $data = array('pickup_datetime'=>$dateStart,'return_datetime'=>$dateEnd,'inventory_id'=>$inventory_id,'order_id'=>$order_id,'block_by'=>'AIRBNB','created_at'=>date("Y-m-d H:i:s"),'description'=>$description);
            $wpdb->insert($wpdb->prefix."rnb_availability",$data);
        }
    }  
    $data = get_order_data($inventory_id,"1");
    //echo '<pre>';
    //print_r($data);
    create_ical($data,'ical_complete_'.$inventory_id.'.ical');  

}

1 个答案:

答案 0 :(得分:0)

您可以使用绝对URL来调用cron文件,例如 'lynx来源“ http://test.com/cron.php”'