Igor, didn't help yet. This is what I have now in MySQL:
mysql> show variables like '%timeout%';
+----------------------------+----------+
| Variable_name | Value |
+----------------------------+----------+
| connect_timeout | 180 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 1800 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 180 |
| net_write_timeout | 120 |
| slave_net_timeout | 3600 |
| wait_timeout | 1800 |
+----------------------------+----------+
10 rows in set (0.00 sec)
Same result, except the script ran for one more minute:
time /usr/local/psa/admin/sbin/statistics
MySQL query failed: MySQL server has gone away
real 35m33.818s
user 24m18.955s
sys 4m36.841s
I've enabled slow query logging and now I'm re-running it.