How to use a Cron Job in Cpanel with PHP - Thumbnail

How to use a Cron Job in Cpanel with PHP

How to use a Cron Job in Cpanel with PHP

How to use a Cron Job in Cpanel with PHP –  is one of the utility programs contained in the Linux operating system, the Cron Job is used to work on executing orders automatically at certain times. Not a Linux command but with a cron job you can also run commands written in PHP language and is saved with extension. PHP, for example, you want to find a daily report sent to each email at 8 a.m., You can even make it more specific to the minute you want to find the report.

Cron Job in Webuzo and Cpanel

Usually the Cron job feature has existed automatically on the Cpanel page, if not you please ask for the vendor of the web hosting provider, this is the image of the Cron Job menu on Webuzo and Cpanel, settle the CRON keyword input in the search menu Then the icon of the Cron Job will appear.

READ  How the Laptop will not turn off/sleep when the Screen is closed
Cron Job Cpanel
Cron Job Cpanel

Please click on his icon then it will appear a page to create a cron job command like this:

<?php
        $fields_string  =   "";
        $fields     =   array(
                            'api_key'       =>  '',
                            'api_secret'    =>  '',
                            'to'            =>  'Your Number Phone',
                            'from'          =>  "Algoritmcomputer.com",
                            'text'          =>  "Your Text Here"
        );
        $url        =   "https://rest.nexmo.com/sms/json";
        //url-ify the data for the POST
    foreach($fields as $key=>$value) { 
            $fields_string .= $key.'='.$value.'&'; 
            }
    rtrim($fields_string, '&');
        //open connection
    $ch = curl_init();
    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
    //execute post
    $result = curl_exec($ch);
    //close connection
    curl_close($ch);
        echo "<pre>";
        print_r($result); 
        echo "</pre>";
?>

 

Then we do the setting Crob job so that this PHP script will be executed automatically every 5 minutes, please do this setting like this and click on the button Add Cron Job.

Add New Cron Job
Add New Cron Job

Explanation Script in the Command column

To use this Cron Job feature, try to master the structure of the system files on the Linux operating system, which is a common command of a barrier used.

READ  How to create a Shortlink using PHP

above script is used to provide the layout information of PHP binary files that are installed on the Web server, maybe the place is opposite to the Web server you use so please customize it

Then the above script is used to show where the PHP files will be run by cron job, OK quite a bit of information about cron job, with there is this feature then you can now create a script that is run automatically by the system.

That’s How to use a Cron Job in Cpanel with PHP easiest by AlgoritmComputer.com, share this article if useful.

Leave a Reply

Your email address will not be published. Required fields are marked *