如何在cPanel中设置PHP CRON作业?

我在cpanel中添加了cronjob以在php中使用textloal发送短信。它在cronjob之外非常有效。在cronjob中运行它后,它不会发送任何短信。


这是我的代码


<?php 

include('dbc.php');


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

require('php-in/textlocal.class.php');

//require('php-in\Textlocal.class.php');


//require('consultantnext.com/danceschool/php-in/Textlocal.class.php');

$sql="SELECT * 

    FROM admin t1, batchinfo t2

    WHERE t1.batchname= t2.batchname  

    AND   t1.branchname= t2.branchname";


$result= mysqli_query($conn,$sql)

or die($sql."<br/><br/>".mysql_error());


if (mysqli_num_rows($result)>0) {

    while($row=mysqli_fetch_array($result)) {


        //echo   $row['mobile'];

        $mobile=$row['mobile'];

        $time=$row['time'];

        //echo $time;

        $numbers=(explode(" ",$mobile));

        foreach ($numbers as $item) {

            echo $item;

        }


        $Textlocal = new Textlocal(false, false, 'e34FsEpkeUo-

   uLJ17oDYeEgHBucRHTnNtHhrE39Pj4');


        //$numbers = array(919384191234,918056377914);

        $sender = 'TXTLCL';

        $message = "Dear student your class schedule for tomorrow '$time'";


        $response = $Textlocal->sendSms($numbers, $message, $sender);

        print_r($response);

        //echo $message;

    }

}



$sql="SELECT   * FROM admin

    WHERE username NOT IN (

    SELECT studentname 

    FROM transcation  

    WHERE MONTH(DATE(date))=MONTH(CURDATE())  

    ) 

    and usertype='student'   ";


$result= mysqli_query($conn, $sql)

or die($sql."<br/><br/>".mysql_error());

If(mysqli_num_rows($result)>0) {


    while($row=mysqli_fetch_array($result)) {

        $username=$row['username'];

        echo $username;

        $mobile=$row['mobile'];


        $numbers=(explode(" ",$mobile));

        foreach ($numbers as $item) {

            echo $item;

        }



这是我的命令:


/usr/local/bin/php /home/cpdarmkr/public_html/danceschool/message.php  


千万里不及你
浏览 117回答 2
2回答

一只名叫tom的猫

这对我有用使用cURL:&nbsp;&nbsp;*/5&nbsp;*&nbsp;*&nbsp;*&nbsp;*&nbsp;curl&nbsp;--silent&nbsp;http://your-website-url/danceschool/message.php

Smart猫小萌

问题可能不在您的代码中,而在您的命令中。也许尝试以下命令,它可能会起作用:*&nbsp;*&nbsp;*&nbsp;*&nbsp;*&nbsp;&nbsp;/usr/bin/php&nbsp;-q&nbsp;/home/cpdarmkr/public_html/danceschool/message.php
打开App,查看更多内容
随时随地看视频慕课网APP