run cron job in octobercms cpanel

142 Views Asked by At

I must update my currency rate and I have this in my Plugin.php:

    public function registerSchedule($schedule) {
        $schedule->call(function () {
            $url = "https://cbu.uz/ru/services/open_data/rates/json/";
            $json = json_decode(file_get_contents($url), true);
            file_put_contents("currency.json", json_encode($json[0]['G4']));            
        })->everyMinute();
    }

I ran my cron job in cPanel

/usr/local/bin/ea-php72 /var/www/u1041398/public_html/agroparts.uz/artisan schedule:run >> /dev/null 2>&1 

The path is correct I checked the PHP version it is correct also. My cron codes in plugin.php are correct also but it is not updating the currency rate. Is this command above correct to run cron job? I checked my code without cron and it worked successfully.

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Cron job was not showing mistake. So, I created console command to update currency rate and run it and it showed

 file_get_contents(): https:// wrapper is disabled in the server configurati  
  on by allow_url_fopen=0                                                      
                            

So I used curl to get currency rate and worked