Oh no! Some styles failed to load. 😵 Please try reloading this page
Menu â–¾ â–´

status.cron.php stopped working after Synology DSM 6 upgrade

Dennis
2016-03-26
2018-10-19
  • Dennis

    Dennis - 2016-03-26

    Hello,

    I have PHP Server Monitoring running on a Synology and after I upgraded DSM to version 6 the scheduled task running the status.cron.php stopped working. On the command line (SSH) I get the following error:

    unable to establish database connection

    The website itself still works fine and manually "Update" works fine too.

    Does anyone has the same problem and managed to solve it?

    Thanks in advance.

    Dennis

     
  • Tomas Halasz

    Tomas Halasz - 2016-03-29

    Hi,

    I have the same issue. The problem is that cron run php script in comand line where is another configuration for php. php.ini which is used in command line doesn't have mysql modules and others which are needed.

    So in my case was solution to change cron script:
    /volume1/@appstore/PHP5.6/usr/local/bin/php56 /volume1/web/phpservermon/cron/status.cron.php

     
  • vletroye

    vletroye - 2017-01-19

    Many thx !!!! I had the same issue.

    I am using now the symlink /usr/local/bin/php56 and it works fine.

    ls -la /usr/local/bin/php56
    /usr/local/bin/php56 -> /var/packages/PHP5.6/target/usr/local/bin/php56

    So: /usr/local/bin/php56 /volume1/web/phpservermon/cron/status.cron.php

     
  • Richard Vertigan

    Thanks for that, very helpful.

     
  • Matthias Hub

    Matthias Hub - 2017-04-15

    Thanks, that helped me also out to get the cron running very quickly!

     
  • Justin O

    Justin O - 2017-09-19

    Anyone tried this with PHP70 ?

    Attempted myself, but getting the same "Unable to establish database connection"

    PDO MySQL is enabled in web station for PHP70

    /volume1/@appstore/PHP7.0/usr/local/bin/php70 /volume1/web/monitor/cron/status.cron.php

     
  • Justin O

    Justin O - 2017-09-19

    I've enabled debugging and now I see this error in the logs..

    Warning: MySQL connection failed: could not find driver in /volume1/web/monitor/src/psm/Service/Database.php on line 525

     
  • carl oppedahl

    carl oppedahl - 2018-04-22

    I have exactly the same problem. I will be so grateful if someone figures out how to fix this.

     
  • gth

    gth - 2018-10-15

    Okay, I managed to fix the connection in Database.php -
    Code before:

    'mysql:host='.$this->db_host.';port='.$this->db_port.';dbname='.$this->db_name.';charset=utf8',
    

    New code:

    'mysql:host='.$this->db_host.':'.$this->db_port.';dbname='.$this->db_name.';charset=utf8',
    

    Not sure if this will affect the cron job's Db connection as well, but it got the front-end working again at least.

     
  • gth

    gth - 2018-10-19

    Just installed the latest 3.3.1 release and reconfirmed the connection issue for my system (and turns out it has nothing to do with Synology). Here's the full working code containing the fix -

    protected function connect() {
            // Initialise connection
    
            // 'localhost' connections use sockets, which requires port to be part of the host parameter
            if ($this->db_host == 'localhost') {
                $connect_string = 'mysql:host='.$this->db_host.':'.$this->db_port.';dbname='.$this->db_name.';charset=utf8';
            } else {
                $connect_string = 'mysql:host='.$this->db_host.';port='.$this->db_port.';dbname='.$this->db_name.';charset=utf8';
            }
    
            try {
                $this->pdo = new \PDO(
                    $connect_string,
                    $this->db_user,
                    $this->db_pass
                );
                $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
                $this->status = true;
            } catch (\PDOException $e) {
                $this->status = false;
                return $this->onConnectFailure($e);
            }
            return $this->pdo;
        }
    

    As per the comment in the code, the hostname 'localhost' is treated differently by the PDO connection code and will cause an error. Since other's posting in this thread are also using Synology, I'm assuming they also specified ' localhost'.

    Reference: http://php.net/manual/en/pdo.connections.php
    Also, apparently Unix sockets are faster than TCP/IP, so this could be a good fix for larger installs. :)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign Up No, Thank you