За последние 24 часа нас посетили 22762 программиста и 1266 роботов. Сейчас ищут 817 программистов ...

Cron в isp панели не работает.

Тема в разделе "Сделайте за меня", создана пользователем ZION3312, 7 фев 2021.

  1. ZION3312

    ZION3312 Активный пользователь

    С нами с:
    9 ноя 2016
    Сообщения:
    14
    Симпатии:
    0
    Через браузер выполняется
    https://сайт.ру/cron/pay?key=O5v1C0f7

    а в isp планировщике не работает
    /usr/bin/wget -t 1 -O - 'https://сайт.ру/cron/pay?key=O5v1C0f7'

    Вот как вылядит внутри
    Код (Text):
    1. <?php
    2. require  'SourceQuery/bootstrap.php';
    3. use xPaw\SourceQuery\SourceQuery;
    4.    
    5. class CronController extends BaseController{
    6.  
    7.     public $backup_folder = 'backups';
    8.    
    9.    
    10.     public function actionPay(){
    11.     $getSettings = $this->db->query('SELECT * FROM ga_settings');
    12.     $settings = $getSettings->fetch();
    13.     $settings = json_decode($settings['content'], true);
    14.  
    15.     if(!isset($_GET['key'])) parent::ShowError(404, "Страница не найдена");
    16.     if($settings['global_settings']['cron_key'] == $_GET['key']){
    17.     $getServers = $this->db->query('SELECT * FROM ga_servers WHERE befirst_enabled != "0" or top_enabled != "0" or vip_enabled !="0" or color_enabled !="0" or gamemenu_enabled !="0"');
    18.     $getServers = $getServers->fetchAll();  
    19.     foreach($getServers as $row){
    20.         if($row['befirst_enabled'] != '0'){
    21.             if($row['befirst_expired_date'] < time()) {
    22.                 $befirst_enabled = 0;
    23.                 $befirst_expired_date = 0;
    24.                 $sql = "UPDATE ga_servers SET befirst_enabled = :befirst_enabled, befirst_expired_date = :befirst_expired_date WHERE id = :id";
    25.                 $update = $this->db->prepare($sql);    
    26.                 $update->bindParam(':befirst_enabled', $befirst_enabled, PDO::PARAM_INT);                                
    27.                 $update->bindParam(':befirst_expired_date', $befirst_expired_date, PDO::PARAM_INT);      
    28.                 $update->bindParam(':id', $row['id'], PDO::PARAM_INT);  
    29.                 $update->execute();
    30.             }
    31.         }
    32.        
    33.         if($row['top_enabled'] != '0'){
    34.             if($row['top_expired_date'] < time()) {
    35.                 $top_enabled = 0;
    36.                 $top_expired_date = 0;
    37.                 $sql = "UPDATE ga_servers SET top_enabled = :top_enabled, top_expired_date = :top_expired_date WHERE id = :id";
    38.                 $update = $this->db->prepare($sql);    
    39.                 $update->bindParam(':top_enabled', $top_enabled, PDO::PARAM_INT);                                
    40.                 $update->bindParam(':top_expired_date', $top_expired_date, PDO::PARAM_INT);      
    41.                 $update->bindParam(':id', $row['id'], PDO::PARAM_INT);  
    42.                 $update->execute();
    43.             }
    44.         }
    45.        
    46.         if($row['vip_enabled'] != '0'){
    47.             if($row['vip_expired_date'] < time()) {
    48.                 $vip_enabled = 0;
    49.                 $vip_expired_date = 0;
    50.                 $sql = "UPDATE ga_servers SET vip_enabled = :vip_enabled, vip_expired_date = :vip_expired_date WHERE id = :id";
    51.                 $update = $this->db->prepare($sql);    
    52.                 $update->bindParam(':vip_enabled', $vip_enabled, PDO::PARAM_INT);                                
    53.                 $update->bindParam(':vip_expired_date', $vip_expired_date, PDO::PARAM_INT);      
    54.                 $update->bindParam(':id', $row['id'], PDO::PARAM_INT);  
    55.                 $update->execute();
    56.             }
    57.         }
    58.        
    59.         if($row['gamemenu_enabled'] != '0'){
    60.             if($row['gamemenu_expired_date'] < time()) {
    61.                 $gamemenu_enabled = 0;
    62.                 $gamemenu_expired_date = 0;
    63.                 $sql = "UPDATE ga_servers SET gamemenu_enabled = :gamemenu_enabled, gamemenu_expired_date = :gamemenu_expired_date WHERE id = :id";
    64.                 $update = $this->db->prepare($sql);    
    65.                 $update->bindParam(':gamemenu_enabled', $gamemenu_enabled, PDO::PARAM_INT);                                
    66.                 $update->bindParam(':gamemenu_expired_date', $gamemenu_expired_date, PDO::PARAM_INT);      
    67.                 $update->bindParam(':id', $row['id'], PDO::PARAM_INT);  
    68.                 $update->execute();
    69.             }
    70.         }
    71.        
    72.         if($row['color_enabled'] != '0'){
    73.             if($row['color_expired_date'] < time()) {
    74.                 $color_enabled = 0;
    75.                 $color_expired_date = 0;
    76.                 $sql = "UPDATE ga_servers SET color_enabled = :color_enabled, color_expired_date = :color_expired_date WHERE id = :id";
    77.                 $update = $this->db->prepare($sql);    
    78.                 $update->bindParam(':color_enabled', $color_enabled, PDO::PARAM_INT);                                
    79.                 $update->bindParam(':color_expired_date', $color_expired_date, PDO::PARAM_INT);      
    80.                 $update->bindParam(':id', $row['id'], PDO::PARAM_INT);  
    81.                 $update->execute();
    82.             }
    83.         }
    84.  
    85.     }
    86.        
    87.     }else parent::ShowError(404, "Страница не найдена");
    88.     }
    89.    
    90.     public function actionIndex(){
    91.     $mem_start = memory_get_usage();
    92.     $getSettings = $this->db->query('SELECT * FROM ga_settings');
    93.     $settings = $getSettings->fetch();
    94.     $settings = json_decode($settings['content'], true);
    95.  
    96.     if(!isset($_GET['key'])) parent::ShowError(404, "Страница не найдена");
    97.     if($settings['global_settings']['cron_key'] == $_GET['key']){
    98.         $getServers = $this->db->query('SELECT * FROM ga_servers');
    99.         $getServers = $getServers->fetchAll();
    100.         $Query = new SourceQuery( );
    101.         $Info = Array( );
    102.         foreach($getServers as $row){
    103.             try
    104.             {
    105.                 $Query->Connect( $row['ip'], $row['port'], 2, SourceQuery::GOLDSOURCE);
    106.                 $Info = $Query->GetInfo( );
    107.                 $status = 1;
    108.                 $sql = "UPDATE ga_servers SET status = :status, hostname = :hostname, map = :map, players = :players, max_players = :max_players WHERE id = :id";
    109.                 $update = $this->db->prepare($sql);    
    110.                 $update->bindParam(':status', $status);                            
    111.                 $update->bindParam(':hostname', $Info['HostName']);      
    112.                 $update->bindParam(':map', $Info['Map']);  
    113.                 $update->bindParam(':players', $Info['Players']);
    114.                 $update->bindParam(':max_players', $Info['MaxPlayers']);
    115.                 $update->bindParam(':id', $row['id']);
    116.                 $update->execute();
    117.             }
    118.             catch( Exception $e ){
    119.                 $Exception = $e;
    120.                 $status = 0;
    121.                 $sql = "UPDATE ga_servers SET status = :status WHERE id = :id";
    122.                 $update = $this->db->prepare($sql);                                
    123.                 $update->bindParam(':status', $status);      
    124.                 $update->bindParam(':id', $row['id']);
    125.                 $update->execute();
    126.             }
    127.             $Query->Disconnect( );
    128.         }
    129.        
    130.     }else parent::ShowError(404, "Страница не найдена");
    131.     $time = time();
    132.     $sql = "UPDATE ga_settings SET last_update_servers = $time";
    133.     $this->db->query($sql);
    134.     echo "server information updated successfully";
    135.     }
    136.    
    137.     public function actionTasks(){
    138.         $getSettings = $this->db->query('SELECT * FROM ga_settings');
    139.         $settings = $getSettings->fetch();
    140.         $settings = json_decode($settings['content'], true);
    141.        
    142.         if(!isset($_GET['key'])) parent::ShowError(404, "Страница не найдена");
    143.         if($settings['global_settings']['cron_key'] == $_GET['key']){
    144.             if($settings['global_settings']['autoBackupDb'] == '1'){
    145.                 $currentDate = date("d-m-Y");
    146.                 $hash = "db_".md5(mt_rand(111,999));
    147.                 $name = $currentDate."-".$hash.".sql";
    148.                 $full_path = $this->backupDB($this->backup_folder ,"$currentDate-$hash");
    149.                 $this->db->exec("INSERT INTO ga_backup (name, type, date_create, hash) VALUES('$name', 'database', ".time().", '$full_path')");
    150.             }
    151.         }
    152.     }
    153.    
    154.     private function backupDB($backup_folder, $backup_name){
    155.         $fullFileName = $backup_folder . '/' . $backup_name . '.sql';
    156.         $command = 'mysqldump -h' . DB_HOST . ' -u' . DB_USER . ' -p' . DB_PASSWORD . ' ' . DB_NAME . ' > ' . $fullFileName;
    157.         shell_exec($command);
    158.         return $fullFileName;
    159.     }
    160.    
    161. }
     
  2. ADSoft

    ADSoft Старожил

    С нами с:
    12 мар 2007
    Сообщения:
    3.824
    Симпатии:
    737
    Адрес:
    Татарстан
    1. Определись, крон не работает - то есть даже не пытается запускать скрипт.
    2. Или же с в скрипте косяк с путям.

    Для этого посмотрите логи ошибок
    Может не wget , а как то по другому?
     
  3. ZION3312

    ZION3312 Активный пользователь

    С нами с:
    9 ноя 2016
    Сообщения:
    14
    Симпатии:
    0
    Ошибку нашел почти. На другой VDS нормально работает. По этому пришлось перенестись немного.