dragonFire

Registered
Aug 9, 2019
4
0
1
Sri Lanka
cPanel Access Level
Root Administrator
this is my corn job : /usr/local/bin/php -q /home/malin/public_html/youtube_api_test/cron_autosave_api_data.php


this is the function i wanna run using corn job
Code:
function getytChannelData($channel_id,$api_key)
{
                
    $data = file_get_contents('https://www.googleapis.com/youtube/v3/channels?part=statistics&id='.$channel_id.'&key='.$api_key);

    return $out = json_decode($data, true );
    
}
json_decode() is not function with the corn job
 
Last edited by a moderator:

dragonFire

Registered
Aug 9, 2019
4
0
1
Sri Lanka
cPanel Access Level
Root Administrator
Does the Cron job function normally when run over the command line or does it also have an issue when run there?
Can I know how to run Cron job over command line?


thing is if I call the file on browser, the function is working fine.

ex: "https://test.example.net/folder_name/test.php" like this
 
Last edited by a moderator:

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
You can run the cron over the command line interface by just using the command you run in the cron:

Code:
 /usr/local/bin/php -q /home/malin/public_html/youtube_api_test/cron_autosave_api_data.php
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
If there was an error with json decode on the system I would anticipate seeing an error being output when you run this. Have you run this script successfully before?