We have problem to run php script via crontab. There are around 70 lines that run scripts installed in different virtual servers. When few lines are executed everything is working but when we have more some of them are not executed.

First we thought that this is crontab issue, but then we figure out that we are getting error from the script 'Error msg: Unable to connect to the database'. Just to let you now this script allow applications, that we have installed on our VPS to execut of the system's scheduled sending script (so you we can schedule our emails to be sent at a later date) on our server.

By getting this error we know that problem exist in the mysql engine. We are not mysql experts so maybe someone knows what to do with this. Here are few outputs from our mysql.

Uptime: 80832  Threads: 60  Questions: 4116373  
Slow queries: 2067  Opens: 69721  Flush tables: 2  
Open tables: 400  Queries per second avg: 50.925


| Variable_name            | Value  |
| Aborted_connects         | 64     |
| Connections              | 671995 |
| Max_used_connections     | 215    |
| Ssl_client_connects      | 0      |
| Ssl_connect_renegotiates | 0      |
| Ssl_finished_connects    | 0      |
| Threads_connected        | 60     |

Do you see something suspicious here? Connections are opened only on localhost. In /etc/my.cnf there is a setup

 bind-address = 
  • Can you post relevant lines from the PHP script(s)? Take care to anonymize/remove sensible data (such as paswords). – Mr Shunz Sep 6 '18 at 9:46
  • 1
    What is your connect_timeout set in mysql? Maybe the clients are timing out. Also you need to gather some more data when this is happening. For example, server load, number of open sockets. – Tux_DEV_NULL Sep 6 '18 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.