提问者:小点点

在php中的cronjob上找不到命令错误


我已经设置了一个cron作业命令来自动增加通过API过帐的货币

 0 0 * * * /usr/bin/php -f /home/wmglobal/public_html/admin/congtienbaohiem.php > /dev/null

和congtienbaohiem.php,其中包含以下代码

$db = mysqli_connect('localhost', 'wmglobal_lixin', 'wmglobal_lixin', 'wmglobal_lixin');
$query = "SELECT * FROM baohiem where trangthai='1'";
$result= $db->query($query);
if ($result->num_rows > 0) {
    while($row = $result ->fetch_assoc()) {
        $sotien = $row['sotien'];
        $username = $row['username'];
        $id = $row['id'];
        $loituc = $sotien * 0.1 /100;

        $gmusername = '789'.$username;
        $gmpassword = $passwordmd5;
        $externalTransactionId = 'WM555BLOBAL'. $id;
        $params=[
                'username'=> $gmusername,
                'amount'=> $loituc,
                'externalTransactionId'=> $externalTransactionId
            ];
        $curl = curl_init();
        curl_setopt_array($curl, array(
        CURLOPT_URL => "https://api.gmaster8.com/WM/credit/deposit",
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => $params,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => array(
        "Authorization: Basic Nzg5QVBJOjEyMzQ1Njc4OTA="
        ),
        CURLOPT_USERPWD => "$gmusername:$gmpassword",
        ));
        curl_exec($curl);
    }
}

但发给我邮箱的结果是

/usr/local/cpanel/bin/jailshell: 0: command not found

我不知道怎么解决这个问题,请帮忙。


共1个答案

匿名用户

我通过将cron job命令更改为

wget http://www.wm555.global/admin/congtienbaohiem.php

并将成功结果发送到电子邮件

--2020-07-06 14:08:02--  http://xxxxxxxx/admin/congtienbaohiem.php
Resolving www.wm555.global... xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx, 104.18.63.120, ...
Connecting to xxxxxxx|104.18.62.120|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “congtienbaohiem.php”
0K                                                        25.8M=0s

2020-07-06 14:08:03 (25.8 MB/s) - “congtienbaohiem.php” saved [83]