Learn Code
Learn Code

Reputation: 21

command not found error on cronjob in php

I have setup a cron job command to auto-increase the mount of money posted via API

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

and the congtienbaohiem.php with this code

$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);
    }
}

But the result sent to my email is

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

I dont know how to solve this, please help.

Upvotes: 0

Views: 552

Answers (1)

Learn Code
Learn Code

Reputation: 21

I have solved this with changing the cron job command to

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

And the successful result sent to email

--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]

Upvotes: 1

Related Questions